From 4e6941ffb0637315dad1c4c95fcefc3899835506 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 19 Feb 2023 15:18:22 +0100 Subject: [PATCH] fix: add missing commands for outdated and pack --- src/npmToPnpm.ts | 9 +++++++++ src/npmToYarn.ts | 11 ++++++++++- test/index.spec.ts | 24 +++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/npmToPnpm.ts b/src/npmToPnpm.ts index 3a1f348..e165e27 100644 --- a/src/npmToPnpm.ts +++ b/src/npmToPnpm.ts @@ -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 + }) } } diff --git a/src/npmToYarn.ts b/src/npmToYarn.ts index 27a781a..356218d 100644 --- a/src/npmToYarn.ts +++ b/src/npmToYarn.ts @@ -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 { diff --git a/test/index.spec.ts b/test/index.spec.ts index a6da012..48d5e62 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -156,6 +156,16 @@ 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'], @@ -163,7 +173,19 @@ describe('NPM tests', () => { ['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', () => {