Skip to content

Instantly share code, notes, and snippets.

@n3dst4
Created August 13, 2014 12:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n3dst4/2be2f130dade862099a5 to your computer and use it in GitHub Desktop.
Save n3dst4/2be2f130dade862099a5 to your computer and use it in GitHub Desktop.
A gulp task that runs "npm install" with options passed thru from command line
gulp.task("install", function(cb) {
var npm = require("npm");
npmConfig = {};
// sample command line opts, you may have others
if (gUtil.env["npm-cache-path"]) npmConfig.cache = gUtil.env["npm-cache-path"];
if (gUtil.env["npm-log-level"]) npmConfig.loglevel = gUtil.env["npm-log-level"];
npm.load(npmConfig, function (er) {
if (er) return cb(er);
npm.commands.install([], function (er, data) { cb(er); });
npm.on("log", function (message) { console.log(message); });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment