Created
August 13, 2014 12:09
-
-
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
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
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