forked from oclif/oclif
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request oclif#1311 from oclif/mdonnalley/validate-pkg-name
fix: validate package name and bin
- Loading branch information
Showing
5 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {expect} from 'chai' | ||
|
||
import {validateBin} from '../../src/util' | ||
|
||
describe('validateBin', () => { | ||
const validBins = [ | ||
'foo', | ||
'foo-bar', | ||
'foo-bar_baz', | ||
'foo_bar', | ||
'foo123', | ||
'123foo', | ||
'foo-bar-', | ||
'foo_bar_', | ||
'-foo-bar', | ||
'_foo_bar', | ||
'123', | ||
] | ||
|
||
const invalidBins = ['foo bar', 'foo!bar'] | ||
it('should return true for valid bins', () => { | ||
for (const bin of validBins) { | ||
expect(validateBin(bin), `${bin} to be valid`).to.be.true | ||
} | ||
}) | ||
|
||
it('should return false for invalid bins', () => { | ||
for (const bin of invalidBins) { | ||
expect(validateBin(bin), `${bin} to be invalid`).to.be.false | ||
} | ||
}) | ||
}) |
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