Skip to content

Commit

Permalink
fix: add missing commands for outdated and pack
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Feb 19, 2023
1 parent 5929271 commit 4e6941f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/npmToPnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ const npmToPnpmTable = {
link: 'link',
unlink (args: string[]) {
return convertFilterArg(args)
},
outdated: 'outdated',
pack: (args: string[]) => {
return args.map(item => {
if (item.startsWith('--pack-destination')) {
return item.replace(/^--pack-destination[\s=]?/, '--pack-destination ')
}
return item
})
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/npmToYarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ const npmToYarnTable = {
},
ln: 'link',
t: 'test',
tst: 'test'
tst: 'test',
outdated: 'outdated',
pack: (args: string[]) => {
return args.map(item => {
if (item.startsWith('--pack-destination')) {
return item.replace(/^--pack-destination[\s=]?/, '--filename ')
}
return item
})
}
}

export function npmToYarn (_m: string, command: string): string {
Expand Down
24 changes: 23 additions & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,36 @@ describe('NPM tests', () => {
'yarn list --pattern "@scope/package|@scope/package2" --depth=2',
'pnpm list @scope/package @scope/package2 --depth 2'
],
[
'npm list @scope/package @scope/package2 --depth 2',
'yarn list --pattern "@scope/package|@scope/package2" --depth 2',
'pnpm list @scope/package @scope/package2 --depth 2'
],
[
'npm list @scope/package --json',
'yarn list --pattern "@scope/package" --json',
'pnpm list @scope/package --json'
],
// link
['npm ln', 'yarn link', 'pnpm link'],
['npm ln package', 'yarn link package', 'pnpm link package'],
['npm link', 'yarn link', 'pnpm link'],
['npm link package', 'yarn link package', 'pnpm link package'],
// unlink
['npm unlink', 'yarn unlink', 'pnpm unlink'],
['npm unlink package', 'yarn unlink package', 'pnpm unlink --filter package']
['npm unlink package', 'yarn unlink package', 'pnpm unlink --filter package'],
// outdated
['npm outdated', 'yarn outdated', 'pnpm outdated'],
['npm outdated --json', 'yarn outdated --json', 'pnpm outdated --json'],
['npm outdated --long', 'yarn outdated --long', 'pnpm outdated --long'],
['npm outdated lodash', 'yarn outdated lodash', 'pnpm outdated lodash'],
// pack
['npm pack', 'yarn pack', 'pnpm pack'],
[
'npm pack --pack-destination=foobar',
'yarn pack --filename foobar',
'pnpm pack --pack-destination foobar'
]
]

describe('to Yarn', () => {
Expand Down

0 comments on commit 4e6941f

Please sign in to comment.