Permalink
Browse files

Add --message option and -m shorthand

Specify commit message when creating a tag

Use --message/-m option when commiting changes in `npm version`.

Mention message option in `npm version` docs

Mention message option in doc/cli/config.md
  • Loading branch information...
1 parent 2999a85 commit d52386b40d1f7896e259b4deb559e8496ef4ecec @mmalecki mmalecki committed with isaacs Sep 26, 2011
Showing with 19 additions and 3 deletions.
  1. +9 −0 doc/cli/config.md
  2. +3 −1 doc/cli/version.md
  3. +3 −0 lib/utils/config-defs.js
  4. +4 −2 lib/version.js
View
@@ -89,6 +89,7 @@ The following shorthands are parsed on the command-line:
* `-ddd`: `--loglevel silly`
* `-g`: `--global`
* `-l`: `--long`
+* `-m`: `--message`
* `-p`, `--porcelain`: `--parseable`
* `-reg`: `--registry`
* `-v`: `--version`
@@ -394,6 +395,14 @@ also "color" and "loglevel".
Show extended information in `npm ls`
+### message
+
+* Default: null
+* Type: [null, String]
+
+Commit message which is used by `npm version` when creating version commit.
+When null, "version <version>" is used.
+
### node-version
* Default: process.version
View
@@ -3,7 +3,7 @@ npm-version(1) -- Bump a package version
## SYNOPSIS
- npm version <newversion>
+ npm version <newversion> [--message commit-message]
## DESCRIPTION
@@ -12,6 +12,8 @@ data back to the package.json file.
If run in a git repo, it will also create a version commit and tag, and
fail if the repo is not clean.
+If supplied with `--message` (shorthand: `-m`) command line option, npm
+will use it as a commit message when creating a version commit.
## SEE ALSO
View
@@ -146,6 +146,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, loglevel : "warn"
, logprefix : process.platform !== "win32"
, long : false
+ , message : "%s"
, "node-version" : process.version
, npaturl : "http://npat.npmjs.org/"
, npat : false
@@ -226,6 +227,7 @@ exports.types =
, loglevel : ["silent","win","error","warn","info","verbose","silly"]
, logprefix : Boolean
, long : Boolean
+ , message: String
, "node-version" : [null, semver]
, npaturl : url
, npat : Boolean
@@ -284,6 +286,7 @@ exports.shorthands =
, "no-desc" : ["--no-description"]
, "local" : ["--no-global"]
, l : ["--long"]
+ , m : ["--message"]
, p : ["--parseable"]
, porcelain : ["--parseable"]
, g : ["--global"]
View
@@ -11,7 +11,8 @@ var exec = require("./utils/exec.js")
, log = require("./utils/log.js")
, npm = require("../npm.js")
-version.usage = "npm version <newversion>\n(run in package dir)\n"
+version.usage = "npm version <newversion> [--message commit-message]"
+ + "\n(run in package dir)\n"
+ "'npm -v' or 'npm --version' to print npm version "
+ "("+npm.version+")\n"
+ "'npm view <pkg> version' to view a package's "
@@ -46,9 +47,10 @@ function checkGit (data, cb) {
"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)
chain
( [ [ exec, "git", ["add","package.json"], process.env, false ]
- , [ exec, "git", ["commit", "-m", "version "+data.version]
+ , [ exec, "git", ["commit", "-m", message ]
, process.env, false ]
, [ exec, "git", ["tag", "v"+data.version], process.env, false ] ]
, cb )

0 comments on commit d52386b

Please sign in to comment.