Skip to content

Instantly share code, notes, and snippets.

@pedrorocha-net
Created February 4, 2015 16:14
Show Gist options
  • Save pedrorocha-net/f9dd0e058b85a325da74 to your computer and use it in GitHub Desktop.
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
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