npm-publish-safe-latest
npm publish
, but doesn't set the "latest" dist-tag to pre-release versions.
See related npm issue.
Installation: npm install npm-publish-safe-latest --save-dev
Example Usage #1
Here's an example workflow for publishing with npm-publish-safe-latest
:
$ git commit -am 'Lots of breaking changes as a v2 major release candidate'[v2-release-candidate 469d6f9] Lots of breaking changes as a major release candidate 100 files changed, 10000000 insertions(+), 0 deletions(-) $ npm version premajorv2.0.0-0 $ ./node_modules/.bin/npm-publish-safe-latestPublishing with dist-tag pre-release+ @scott113341/my-module@v2.0.0-0 $ npm info my-module dist-tags{ latest: '1.22.4', 'pre-release': '2.0.0-0' }
Notice how our dist-tag
was set to pre-release
instead of latest
? That's good. If we had used npm publish
instead:
- Our
latest
dist-tag
would have been set tov2.0.0-0
- Anyone running
npm install my-module
would have gotten our unstablev2.0.0-0
release candidate
Disaster averted!
If you want to specify the dist-tag
, you can pass it in as the first argument. For example, let's say we instead of the default pre-release
tag, we wanted to tag our v2.0.0-0
as v2-rc
:
$ ./node_modules/.bin/npm-publish-safe-latest v2-rcPublishing with dist-tag v2-rc+ @scott113341/my-module@v2.0.0-0 $ npm info my-module dist-tags{ latest: '1.22.4', 'v2-rc': '2.0.0-0' }
Example Usage #2
Let's say you want to get crazy and automatically publish stuff after you version your package. In your package.json
:
{ // ... "scripts": { "preversion": "npm run test", "postversion": "npm-publish-safe-latest && git push --follow-tags", "test": "node test/index.js" }, // ...}
Let's say you run npm version premajor
. Here's what'll happen:
- Tests run; the entire process is aborted if they fail
- The package version gets bumped a major pre-release version (to something like
v2.0.0-0
) - The package is published. Since it's a pre-release version, the
dist-tag
is set topre-release
instead oflatest
- Changes (including tags) are pushed to your git origin
Full Usage
usage: npm-publish-safe-latest [not-latest-tag] [-- options...] not-latest-tag the dist-tag if the version being published is a pre-release version default: "pre-release" options arguments that will be forwarded to `npm publish`