fix: allow the $ sign to be a command name (#3751)

close #3679
This commit is contained in:
Zoltan Kochan
2021-09-06 23:39:08 +03:00
committed by GitHub
parent e0aa55140c
commit 97f90e5373
3 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/package-bins": patch
---
Allow the \$ sign to be a command name.

View File

@@ -48,7 +48,7 @@ function commandsFromBin (bin: PackageBin, pkgName: string, pkgPath: string) {
]
}
return Object.keys(bin)
.filter((commandName) => encodeURIComponent(commandName) === commandName)
.filter((commandName) => encodeURIComponent(commandName) === commandName || commandName === '$')
.map((commandName) => ({
name: commandName,
path: path.join(pkgPath, bin[commandName]),

View File

@@ -15,6 +15,22 @@ test('getBinsFromPkg()', async () => {
)
})
test('getBinsFromPkg() should allow $ as command name', async () => {
expect(
await getBinsFromPkg({
bin: {
$: './undollar.js',
},
name: 'undollar',
version: '1.0.0',
}, process.cwd())).toStrictEqual(
[{
name: '$',
path: path.resolve('undollar.js'),
}]
)
})
test('find all the bin files from a bin directory', async () => {
const fixtures = path.join(__dirname, 'fixtures')
expect(