Skip to content

Instantly share code, notes, and snippets.

@axemclion
Created March 4, 2013 05:22
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 axemclion/5080136 to your computer and use it in GitHub Desktop.
Save axemclion/5080136 to your computer and use it in GitHub Desktop.
A grunt task to publish npm packages from CI environments like travis
grunt.registerMultiTask('publish', 'Publish the latest version of this plugin', function() {
var done = this.async(),
me = this,
npm = require('npm');
npm.load({}, function(err) {
npm.registry.adduser(me.data.username, me.data.password, me.data.email, function(err) {
if (err) {
console.log(err);
done(false);
} else {
npm.config.set("email", me.data.email, "user");
npm.commands.publish([], function(err) {
console.log(err || "Published to registry");
done(!err);
});
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment