Skip to content

Instantly share code, notes, and snippets.

@geddski
Created March 16, 2012 19:35
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 geddski/2052081 to your computer and use it in GitHub Desktop.
Save geddski/2052081 to your computer and use it in GitHub Desktop.
test programmatic npm install
var npm = require('npm');
npmInstall(['http://dl.dropbox.com/u/3098507/sample.tar.gz'], function () {
console.log('yay');
});
/*
programmatically install some libs with npm
working in OSX but not windows
*/
function npmInstall(libs, callback){
npm.load({}, function (er) {
if (er) throw new Error(er);
npm.commands.install(libs, function (er, data) {
if (er) throw new Error(er);
callback.call(this);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment