Skip to content

Commit

Permalink
Add tests option (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisblossom authored and sindresorhus committed Jun 29, 2019
1 parent 1c9d05f commit bea57db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $ np --help
Options
--any-branch Allow publishing from any branch
--no-cleanup Skips cleanup of node_modules
--no-tests Skips tests
--yolo Skips cleanup and testing
--no-publish Skips publishing
--tag Publish under a given dist-tag
Expand Down Expand Up @@ -92,6 +93,7 @@ Currently, these are the flags you can configure:

- `anyBranch` - Allow publishing from any branch (`false` by default).
- `cleanup` - Cleanup `node_modules` (`true` by default).
- `tests` - Run `npm test` (`true` by default).
- `yolo` - Skip cleanup and testing (`false` by default).
- `publish` - Publish (`true` by default).
- `tag` - Publish under a given dist-tag (`latest` by default).
Expand Down
5 changes: 5 additions & 0 deletions source/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const cli = meow(`
Options
--any-branch Allow publishing from any branch
--no-cleanup Skips cleanup of node_modules
--no-tests Skips tests
--yolo Skips cleanup and testing
--no-publish Skips publishing
--tag Publish under a given dist-tag
Expand All @@ -45,6 +46,9 @@ const cli = meow(`
cleanup: {
type: 'boolean'
},
tests: {
type: 'boolean'
},
yolo: {
type: 'boolean'
},
Expand Down Expand Up @@ -74,6 +78,7 @@ updateNotifier({pkg: cli.pkg}).notify();

const defaultFlags = {
cleanup: true,
tests: true,
publish: true,
yarn: hasYarn()
};
Expand Down
3 changes: 2 additions & 1 deletion source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const exec = (cmd, args) => {
module.exports = async (input = 'patch', options) => {
options = {
cleanup: true,
tests: true,
publish: true,
...options
};
Expand All @@ -51,7 +52,7 @@ module.exports = async (input = 'patch', options) => {
}

const pkg = util.readPkg();
const runTests = !options.yolo;
const runTests = options.tests && !options.yolo;
const runCleanup = options.cleanup && !options.yolo;
const runPublish = options.publish && !pkg.private;
const pkgManager = options.yarn === true ? 'yarn' : 'npm';
Expand Down

0 comments on commit bea57db

Please sign in to comment.