Permalink
Browse files

Add sign-git-tag config for 'npm version' command

  • Loading branch information...
1 parent 1fd1bdc commit 3072804a006d310e7aae104e08a8135c49afd6f6 @isaacs isaacs committed Jul 12, 2012
Showing with 19 additions and 2 deletions.
  1. +11 −0 doc/cli/config.md
  2. +2 −0 lib/utils/config-defs.js
  3. +6 −2 lib/version.js
View
@@ -694,6 +694,17 @@ character to indicate reverse sort.
The shell to run for the `npm explore` command.
+### sign-git-tag
+
+* Default: false
+* Type: Boolean
+
+If set to true, then the `npm version` command will tag the version
+using `-s` to add a signature.
+
+Note that git requires you to have set up GPG keys in your git configs
+for this to work properly.
+
### strict-ssl
* Default: true
View
@@ -189,6 +189,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, searchexclude: null
, searchsort: "name"
, shell : osenv.shell()
+ , "sign-git-tag": false
, "strict-ssl": true
, tag : "latest"
, tmp : temp
@@ -280,6 +281,7 @@ exports.types =
, "date", "-date"
, "keywords", "-keywords" ]
, shell : String
+ , "sign-git-tag": Boolean
, "strict-ssl": Boolean
, tag : String
, tmp : path
View
@@ -10,7 +10,7 @@ var exec = require("./utils/exec.js")
, log = require("npmlog")
, npm = require("./npm.js")
-version.usage = "npm version <newversion> [--message commit-message]"
+version.usage = "npm version [<newversion> | major | minor | patch | build]\n"
+ "\n(run in package dir)\n"
+ "'npm -v' or 'npm --version' to print npm version "
+ "("+npm.version+")\n"
@@ -52,19 +52,23 @@ function checkGit (data, cb) {
, function (er, code, stdout, stderr) {
var lines = stdout.trim().split("\n").filter(function (line) {
return line.trim() && !line.match(/^\?\? /)
+ }).map(function (line) {
+ return line.trim()
})
if (lines.length) return cb(new Error(
"Git working directory not clean.\n"+lines.join("\n")))
write(data, function (er) {
if (er) return cb(er)
var message = npm.config.get("message").replace(/%s/g, data.version)
+ , sign = npm.config.get("sign-git-tag")
+ , flag = sign ? "-sm" : "-am"
chain
( [ [ exec, npm.config.get("git")
, ["add","package.json"], process.env, false ]
, [ exec, npm.config.get("git")
, ["commit", "-m", message ], process.env, false ]
, [ exec, npm.config.get("git")
- , ["tag", "v"+data.version], process.env, false ] ]
+ , ["tag", "v"+data.version, flag, message], process.env, false ] ]
, cb )
})
})

0 comments on commit 3072804

Please sign in to comment.