Skip to content

Instantly share code, notes, and snippets.

@matyb
Created September 13, 2017 04:23
Show Gist options
  • Save matyb/249eac58d2aba51e4c60c037f5043eea to your computer and use it in GitHub Desktop.
Save matyb/249eac58d2aba51e4c60c037f5043eea to your computer and use it in GitHub Desktop.
Multi Module Node Gulpfile
const gulp = require('gulp');
const { spawn } = require('child_process');
const { join } = require('path');
const gulpmodules = ['./src_modules/common',
'./src_modules/client',
'./src_modules/server'];
const moduleTasks = ['default', 'clean', 'build', 'test']
function moduleTask(taskNames) {
return () => {
gulpmodules.forEach((dir) => {
process.chdir(join(__dirname, dir));
const gulpCmd = /^win/.test(process.platform) ? 'gulp.cmd' : 'gulp';
const child = spawn(gulpCmd, taskNames, { customFds: [0,1,2] });
child.on('exit', console.log);
});
};
};
moduleTasks.forEach((task) => { gulp.task(task, moduleTask([task]));} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment