Permalink
Browse files

skip publishing if package is flagged as private (#64)

* Don't attempt to npm publish if package flagged as private

* Missing semicolon

* Change to using load-json-file

* Use read-pkg-up to read package.json

* Fix lint error

* Document private packages in readme

* Use readPkgUp.sync
  • Loading branch information...
1 parent 4954429 commit 4a5a090a0a3b33ac707a0eca8f3241699d70ccf3 @unkillbob unkillbob committed with jamestalmage Jul 22, 2016
Showing with 19 additions and 7 deletions.
  1. +10 −6 index.js
  2. +1 −1 package.json
  3. BIN private-packages.png
  4. +8 −0 readme.md
View
@@ -1,16 +1,14 @@
'use strict';
-const fs = require('fs');
const semver = require('semver');
const execa = require('execa');
const del = require('del');
-const pify = require('pify');
const Listr = require('listr');
const split = require('split');
require('any-observable/register/rxjs-all');
const Observable = require('any-observable');
const streamToObservable = require('stream-to-observable');
+const readPkgUp = require('read-pkg-up');
-const fsP = pify(fs);
const VERSIONS = ['major', 'minor', 'patch', 'premajor', 'preminor', 'prepatch', 'prerelease'];
const exec = (cmd, args) => {
@@ -116,7 +114,13 @@ module.exports = (input, opts) => {
},
{
title: 'Publishing package',
- task: () => exec('npm', ['publish'].concat(opts.tag ? ['--tag', opts.tag] : []))
+ task: () => {
+ if (readPkgUp.sync().pkg.private) {
+ return 'Private package: publishing skipped.';
+ }
+
+ return exec('npm', ['publish'].concat(opts.tag ? ['--tag', opts.tag] : []));
+ }
},
{
title: 'Pushing tags',
@@ -125,6 +129,6 @@ module.exports = (input, opts) => {
]);
return tasks.run()
- .then(() => fsP.readFile('package.json', 'utf8'))
- .then(JSON.parse);
+ .then(() => readPkgUp())
+ .then(result => result.pkg);
};
View
@@ -37,7 +37,7 @@
"execa": "^0.4.0",
"listr": "^0.4.3",
"meow": "^3.7.0",
- "pify": "^2.3.0",
+ "read-pkg-up": "^1.0.1",
"rxjs": "^5.0.0-beta.9",
"semver": "^5.1.0",
"split": "^1.0.0",
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -72,6 +72,14 @@ Set the [`sign-git-tag`](https://docs.npmjs.com/misc/config#sign-git-tag) npm co
$ npm config set sign-git-tag true
```
+### Private packages
+
+You can use np for modules that aren't publicly published to npm (perhaps installed from a private git repo).
+
+Set `"private": true` in your `package.json` and the publish step will be skipped. All other steps
+including versioning and pushing tags will still be completed.
+
+<img src="private-packages.png" width="306">
## License

0 comments on commit 4a5a090

Please sign in to comment.