Skip to content

Commit

Permalink
Merge pull request #45 from OzakIOne/fix/npmToPnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
nebrelbug committed Feb 15, 2024
2 parents 233ff64 + cb2f7df commit 8fc22ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/npmToPnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ const npmToPnpmTable = {
export function npmToPnpm (_m: string, command: string): string {
let args = parse((command || '').trim())

const index = args.findIndex(a => a === '--')
if (index >= 0) {
args.splice(index, 1)
}

if (args[0] in npmToPnpmTable) {
const converter = npmToPnpmTable[args[0] as keyof typeof npmToPnpmTable]

Expand Down
10 changes: 5 additions & 5 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ describe('NPM tests', () => {
[
'npm run test -- --version',
'yarn run test --version',
'pnpm run test -- --version',
'pnpm run test --version',
'bun run test --version',
],
['npm run test -- -v', 'yarn run test -v', 'pnpm run test -- -v', 'bun run test -v'],
['npm run test -- -v', 'yarn run test -v', 'pnpm run test -v', 'bun run test -v'],
['npm run custom', 'yarn custom', 'pnpm run custom', 'bun run custom'],
['npm run add', 'yarn run add', 'pnpm run add', 'bun run add'],
['npm run install', 'yarn run install', 'pnpm run install', 'bun run install'],
Expand All @@ -180,18 +180,18 @@ describe('NPM tests', () => {
['npm exec add', 'yarn run add', 'pnpm exec add', 'bunx add'],
['npm exec install', 'yarn run install', 'pnpm exec install', 'bunx install'],
['npm exec run', 'yarn run run', 'pnpm exec run', 'bunx run'],
['npm exec custom -- --version', 'yarn custom --version', 'pnpm exec custom -- --version', 'bunx custom --version'],
['npm exec custom -- --version', 'yarn custom --version', 'pnpm exec custom --version', 'bunx custom --version'],
// test
['npm test', 'yarn test', 'pnpm test', 'bun run test'],
['npm t', 'yarn test', 'pnpm test', 'bun run test'],
['npm tst', 'yarn test', 'pnpm test', 'bun run test'],
[
'npm test -- --version',
'yarn test --version',
'pnpm test -- --version',
'pnpm test --version',
'bun run test --version',
],
['npm test -- -v', 'yarn test -v', 'pnpm test -- -v', 'bun run test -v'],
['npm test -- -v', 'yarn test -v', 'pnpm test -v', 'bun run test -v'],
// unchanged
['npm start', 'yarn start', 'pnpm start', 'bun start'],
['npm stop', 'yarn stop', "npm stop\n# couldn't auto-convert command", 'bun stop'],
Expand Down

0 comments on commit 8fc22ec

Please sign in to comment.