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 4304218
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 6 deletions.
20 changes: 19 additions & 1 deletion dist/npm-to-yarn.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,16 @@ var npmToYarnTable = {
},
ln: 'link',
t: 'test',
tst: 'test'
tst: 'test',
outdated: 'outdated',
pack: function (args) {
return args.map(function (item) {
if (item.startsWith('--pack-destination')) {
return item.replace(/^--pack-destination[\s=]/, '--filename ');
}
return item;
});
}
};
function npmToYarn(_m, command) {
var args = parse((command || '').trim());
Expand Down Expand Up @@ -449,6 +458,15 @@ var npmToPnpmTable = {
link: 'link',
unlink: function (args) {
return convertFilterArg(args);
},
outdated: 'outdated',
pack: function (args) {
return args.map(function (item) {
if (item.startsWith('--pack-destination')) {
return item.replace(/^--pack-destination[\s=]/, '--pack-destination ');
}
return item;
});
}
};
function npmToPnpm(_m, command) {
Expand Down
2 changes: 1 addition & 1 deletion dist/npm-to-yarn.mjs.map

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion dist/npm-to-yarn.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/npm-to-yarn.umd.js.map

Large diffs are not rendered by default.

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 4304218

Please sign in to comment.