Permalink
Browse files

Add `--no-publish` flag (#113)

  • Loading branch information...
1 parent 82e33a5 commit ca0f193170618547a56c130cddc8bfd86e3c8f00 @Moeriki Moeriki committed with Dec 13, 2016
Showing with 24 additions and 14 deletions.
  1. +1 −0 cli.js
  2. +18 −14 index.js
  3. +5 −0 readme.md
View
@@ -18,6 +18,7 @@ const cli = meow(`
--any-branch Allow publishing from any branch
--no-cleanup Skips cleanup of node_modules
--yolo Skips cleanup and testing
+ --no-publish Skips publishing
--tag Publish under a given dist-tag
Examples
View
@@ -25,7 +25,8 @@ module.exports = (input, opts) => {
input = input || 'patch';
opts = Object.assign({
- cleanup: true
+ cleanup: true,
+ publish: true
}, opts);
// TODO: remove sometime far in the future
@@ -35,6 +36,7 @@ module.exports = (input, opts) => {
const runTests = !opts.yolo;
const runCleanup = opts.cleanup && !opts.yolo;
+ const runPublish = opts.publish;
const pkg = util.readPkg();
const tasks = new Listr([
@@ -70,26 +72,28 @@ module.exports = (input, opts) => {
});
}
- tasks.add([
- {
- title: 'Bumping version',
- // Specify --force flag to proceed even if the working directory is dirty as np already does a dirty check anyway
- task: () => exec('npm', ['version', input, '--force'])
- },
- {
+ tasks.add({
+ title: 'Bumping version',
+ // Specify --force flag to proceed even if the working directory is dirty as np already does a dirty check anyway
+ task: () => exec('npm', ['version', input, '--force'])
+ });
+
+ if (runPublish) {
+ tasks.add({
title: 'Publishing package',
skip: () => {
if (pkg.private) {
return 'Private package: not publishing to npm.';
}
},
task: () => exec('npm', ['publish'].concat(opts.tag ? ['--tag', opts.tag] : []))
- },
- {
- title: 'Pushing tags',
- task: () => exec('git', ['push', '--follow-tags'])
- }
- ]);
+ });
+ }
+
+ tasks.add({
+ title: 'Pushing tags',
+ task: () => exec('git', ['push', '--follow-tags'])
+ });
return tasks.run()
.then(() => readPkgUp())
View
@@ -40,6 +40,7 @@ $ np --help
--any-branch Allow publishing from any branch
--no-cleanup Skips cleanup of node_modules
--yolo Skips cleanup and testing
+ --no-publish Skips publishing
--tag Publish under a given dist-tag
Examples
@@ -111,6 +112,10 @@ Set the [`registry` option](https://docs.npmjs.com/misc/config#registry) in pack
}
```
+### Publish with a CI
+
+If you use a Continuous Integration server to publish your tagged commits, use the `--no-publish` flag to skip the publishing step of `np`.
+
### Initial version
For new packages, start the `version` field in package.json at `0.0.0` and let `np` bump it to `1.0.0` or `0.1.0` when publishing.

0 comments on commit ca0f193

Please sign in to comment.