-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow explicit private publish to prevent public publish prompt (#497)
Co-authored-by: Itai Steinherz <[email protected]>
- Loading branch information
1 parent
5f52e81
commit 08b52a2
Showing
5 changed files
with
43 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
import test from 'ava'; | ||
import np from '../source'; | ||
|
||
const defaultOptions = { | ||
cleanup: true, | ||
tests: true, | ||
publish: true, | ||
runPublish: true | ||
}; | ||
|
||
test('version is invalid', async t => { | ||
const message = 'Version should be either patch, minor, major, prepatch, preminor, premajor, prerelease, or a valid semver version.'; | ||
await t.throwsAsync(np('foo'), message); | ||
await t.throwsAsync(np('4.x.3'), message); | ||
await t.throwsAsync(np('foo', defaultOptions), message); | ||
await t.throwsAsync(np('4.x.3', defaultOptions), message); | ||
}); | ||
|
||
test('version is pre-release', async t => { | ||
const message = 'You must specify a dist-tag using --tag when publishing a pre-release version. This prevents accidentally tagging unstable versions as "latest". https://docs.npmjs.com/cli/dist-tag'; | ||
await t.throwsAsync(np('premajor'), message); | ||
await t.throwsAsync(np('preminor'), message); | ||
await t.throwsAsync(np('prepatch'), message); | ||
await t.throwsAsync(np('prerelease'), message); | ||
await t.throwsAsync(np('10.0.0-0'), message); | ||
await t.throwsAsync(np('10.0.0-beta'), message); | ||
await t.throwsAsync(np('premajor', defaultOptions), message); | ||
await t.throwsAsync(np('preminor', defaultOptions), message); | ||
await t.throwsAsync(np('prepatch', defaultOptions), message); | ||
await t.throwsAsync(np('prerelease', defaultOptions), message); | ||
await t.throwsAsync(np('10.0.0-0', defaultOptions), message); | ||
await t.throwsAsync(np('10.0.0-beta', defaultOptions), message); | ||
}); | ||
|
||
test('errors on too low version', async t => { | ||
await t.throwsAsync(np('1.0.0'), /New version `1\.0\.0` should be higher than current version `\d+\.\d+\.\d+`/); | ||
await t.throwsAsync(np('1.0.0-beta'), /New version `1\.0\.0-beta` should be higher than current version `\d+\.\d+\.\d+`/); | ||
await t.throwsAsync(np('1.0.0', defaultOptions), /New version `1\.0\.0` should be higher than current version `\d+\.\d+\.\d+`/); | ||
await t.throwsAsync(np('1.0.0-beta', defaultOptions), /New version `1\.0\.0-beta` should be higher than current version `\d+\.\d+\.\d+`/); | ||
}); |