Created
February 4, 2015 16:14
-
-
Save pedrorocha-net/f9dd0e058b85a325da74 to your computer and use it in GitHub Desktop.
Gulp task to concatenate all JS files from a Drupal website active modules with Gulp + Coffeescript + Drush
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drush = require 'drush-node' | |
destinations = | |
js: 'assets/js' | |
gulp.task 'drupal-minifyjs', -> | |
drush.init() | |
.then () -> | |
drush.exec('php-eval "print realpath(\'.\')"') | |
.then (realpath) -> | |
drush.exec('sqlq "SELECT filename FROM system WHERE type = \'module\' AND status = 1"') | |
.then (res) -> | |
lines = res.split("\n") | |
modules_folders = [] | |
for line in lines | |
if line.length > 0 | |
folders = line.split("/") | |
folders.pop() | |
module_path = "#{realpath}/" + folders.join('/') + "/**/*.js" | |
modules_folders.push module_path | |
gulp.src(modules_folders) | |
.pipe($.concat('website-full.js')) | |
.pipe(gulp.dest(destinations.js)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment