diff --git a/src/npmToBun.ts b/src/npmToBun.ts index e080b44..fd01f83 100644 --- a/src/npmToBun.ts +++ b/src/npmToBun.ts @@ -104,7 +104,7 @@ export function npmToBun (_m: string, command: string): string { args = args.slice(1) } else if (!args[1].startsWith('-')) { cmd = 'bunx' - args[1] = `create-${args[1]}` + args[1] = `create-${args[1].replace('@latest', '')}` args = args.slice(1) } else { args[0] = 'init' diff --git a/src/npmToPnpm.ts b/src/npmToPnpm.ts index 53ec848..c64566c 100644 --- a/src/npmToPnpm.ts +++ b/src/npmToPnpm.ts @@ -97,9 +97,16 @@ const npmToPnpmTable = { init (args: string[]) { if (args[1] && !args[1].startsWith('-')) { args[0] = 'create' + const m = args[1].match(/(.+)@latest/) + if (m) { + args[1] = m[1] + } } return args.filter(item => item !== '--scope') }, + create (args: string[]) { + return npmToPnpmTable.init(args) + }, ln: 'link', t: 'test', test: 'test', diff --git a/src/npmToYarn.ts b/src/npmToYarn.ts index 3368268..c937dca 100644 --- a/src/npmToYarn.ts +++ b/src/npmToYarn.ts @@ -116,9 +116,16 @@ const npmToYarnTable = { init (args: string[]) { if (args[1] && !args[1].startsWith('-')) { args[0] = 'create' + const m = args[1].match(/(.+)@latest/) + if (m) { + args[1] = m[1] + } } return args.filter(item => item !== '--scope') }, + create (args: string[]) { + return npmToYarnTable.init(args) + }, ln: 'link', t: 'test', tst: 'test', diff --git a/test/index.spec.ts b/test/index.spec.ts index f8d6992..10e5635 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -227,6 +227,19 @@ describe('NPM tests', () => { 'pnpm create react-app ./my-react-app', 'bunx create-react-app ./my-react-app', ], + // create + [ + 'npm create react-app ./my-react-app', + 'yarn create react-app ./my-react-app', + 'pnpm create react-app ./my-react-app', + 'bunx create-react-app ./my-react-app', + ], + [ + 'npm create vite@latest', + 'yarn create vite', + 'pnpm create vite', + 'bunx create-vite', + ], // list ['npm list', 'yarn list', 'pnpm list', 'bun pm ls'], ['npm ls', 'yarn list', 'pnpm ls', 'bun pm ls'], @@ -648,4 +661,4 @@ describe('to bun x tests', () => { expect(convert(npmValue, 'bun')).toEqual(bunValue) }) }) -}) \ No newline at end of file +})