Skip to content

Commit 8fc22ec

Browse files
authored
Merge pull request #45 from OzakIOne/fix/npmToPnpm
2 parents 233ff64 + cb2f7df commit 8fc22ec

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/npmToPnpm.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const npmToPnpmTable = {
123123
export function npmToPnpm (_m: string, command: string): string {
124124
let args = parse((command || '').trim())
125125

126+
const index = args.findIndex(a => a === '--')
127+
if (index >= 0) {
128+
args.splice(index, 1)
129+
}
130+
126131
if (args[0] in npmToPnpmTable) {
127132
const converter = npmToPnpmTable[args[0] as keyof typeof npmToPnpmTable]
128133

test/index.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ describe('NPM tests', () => {
168168
[
169169
'npm run test -- --version',
170170
'yarn run test --version',
171-
'pnpm run test -- --version',
171+
'pnpm run test --version',
172172
'bun run test --version',
173173
],
174-
['npm run test -- -v', 'yarn run test -v', 'pnpm run test -- -v', 'bun run test -v'],
174+
['npm run test -- -v', 'yarn run test -v', 'pnpm run test -v', 'bun run test -v'],
175175
['npm run custom', 'yarn custom', 'pnpm run custom', 'bun run custom'],
176176
['npm run add', 'yarn run add', 'pnpm run add', 'bun run add'],
177177
['npm run install', 'yarn run install', 'pnpm run install', 'bun run install'],
@@ -180,18 +180,18 @@ describe('NPM tests', () => {
180180
['npm exec add', 'yarn run add', 'pnpm exec add', 'bunx add'],
181181
['npm exec install', 'yarn run install', 'pnpm exec install', 'bunx install'],
182182
['npm exec run', 'yarn run run', 'pnpm exec run', 'bunx run'],
183-
['npm exec custom -- --version', 'yarn custom --version', 'pnpm exec custom -- --version', 'bunx custom --version'],
183+
['npm exec custom -- --version', 'yarn custom --version', 'pnpm exec custom --version', 'bunx custom --version'],
184184
// test
185185
['npm test', 'yarn test', 'pnpm test', 'bun run test'],
186186
['npm t', 'yarn test', 'pnpm test', 'bun run test'],
187187
['npm tst', 'yarn test', 'pnpm test', 'bun run test'],
188188
[
189189
'npm test -- --version',
190190
'yarn test --version',
191-
'pnpm test -- --version',
191+
'pnpm test --version',
192192
'bun run test --version',
193193
],
194-
['npm test -- -v', 'yarn test -v', 'pnpm test -- -v', 'bun run test -v'],
194+
['npm test -- -v', 'yarn test -v', 'pnpm test -v', 'bun run test -v'],
195195
// unchanged
196196
['npm start', 'yarn start', 'pnpm start', 'bun start'],
197197
['npm stop', 'yarn stop', "npm stop\n# couldn't auto-convert command", 'bun stop'],

0 commit comments

Comments
 (0)