Skip to content

Instantly share code, notes, and snippets.

@ayapi
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayapi/c0ab6a6b1cd89fe7572a to your computer and use it in GitHub Desktop.
Save ayapi/c0ab6a6b1cd89fe7572a to your computer and use it in GitHub Desktop.
gulp task for `nw-gyp` to all dependencies recursively
// usage
// just
// `gulp nw-gyp`
// or type node-webkit version
// `gulp nw-gyp --target 0.9.2`
var gulp = require('gulp');
var exec = require('gulp-exec');
var minimist = require('minimist');
gulp.task('nw-gyp', function(){
var knownOptions = {
string: 'target',
default: { 'target': '0.10.5' }
};
var options = minimist(process.argv.slice(2), knownOptions);
var execOptions = {
continueOnError: false,
pipeStdout: false
};
var reportOptions = {
err: true,
stderr: true,
stdout: true
};
var pkg = require('./package.json');
var modules = [];
if(!!pkg.dependencies){
modules = Object.keys(pkg.dependencies)
.filter(function(m){
return m != 'nodewebkit'
})
.map(function(m){
return './node_modules/' + m + '/**/binding.gyp'
})
}
return gulp.src(modules)
.pipe(exec(
'cd "<%= file.path %>/../"' +
' && nw-gyp configure --target=' + options.target +
' && nw-gyp build'
), execOptions)
.pipe(exec.reporter(reportOptions));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment