Skip to content

Commit ede41d5

Browse files
committed
NPM: Add npmTags() to provide full control over which tags are used
Fixes gh-29 Fixes gh-30 Closes gh-48
1 parent 0d86e9d commit ede41d5

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ the shell, the commit log, and the issue list.
114114
If using Trac, return a different milestone to be used in the queries to
115115
generate a changelog and list of contributors. Defaults to `newVersion`.
116116

117+
#### npmTags()
118+
119+
An array of tags to apply to the npm release. Every release must contain at least
120+
one tag.
121+
117122
#### issueTracker
118123

119124
Which type of issue tracker is being used for the project. Must be either

lib/npm.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,46 @@ module.exports = function( Release ) {
3838
}
3939
},
4040

41+
npmTags: function() {
42+
var tags = [ "beta" ];
43+
44+
if ( !Release.preRelease ) {
45+
tags.push( "latest" );
46+
}
47+
48+
return tags;
49+
},
50+
4151
_publishNpm: function() {
4252
if ( !Release.npmPublish ) {
4353
return;
4454
}
4555

4656
Release.chdir( Release.dir.repo );
4757

48-
var npmCommand = "npm publish";
58+
var name = Release.readPackage().name,
59+
npmTags = Release.npmTags(),
60+
npmCommand = "npm publish --tag " + npmTags.pop();
4961

50-
if ( Release.preRelease ) {
51-
npmCommand += " --tag beta";
62+
if ( Release.isTest ) {
63+
console.log( "Actual release would now publish to npm using:" );
64+
} else {
65+
console.log( "Publishing to npm, running:" );
5266
}
5367

54-
if ( Release.isTest ) {
55-
console.log( "Actual release would now publish to npm" );
56-
console.log( "Would run: " + npmCommand.cyan );
57-
return;
68+
console.log( " " + npmCommand.cyan );
69+
if ( !Release.isTest ) {
70+
Release.exec( npmCommand );
71+
}
72+
73+
while ( npmTags.length ) {
74+
npmCommand = "npm tag " + name + "@" + Release.newVersion + " " + npmTags.pop();
75+
console.log( " " + npmCommand.cyan );
76+
if ( !Release.isTest ) {
77+
Release.exec( npmCommand );
78+
}
5879
}
5980

60-
console.log( "Publishing to npm, running " + npmCommand.cyan );
61-
Release.exec( npmCommand );
6281
console.log();
6382
}
6483
});

0 commit comments

Comments
 (0)