Created
March 4, 2013 05:22
-
-
Save axemclion/5080136 to your computer and use it in GitHub Desktop.
A grunt task to publish npm packages from CI environments like travis
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
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