Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: -- argument error #45

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading