From 5ef1887ea96d529bf6bd4e52d6d77ffbd6baf13e Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 6 Feb 2021 14:10:17 +0800 Subject: [PATCH] fix(cli): new command without npm scope --- cli/src/new/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/src/new/index.ts b/cli/src/new/index.ts index ac179125..2c225d51 100644 --- a/cli/src/new/index.ts +++ b/cli/src/new/index.ts @@ -71,7 +71,8 @@ export class NewProjectCommand extends Command { async execute() { await this.getName() if (!this.dirname) { - const [, defaultProjectDir] = this.name?.split('/') ?? [] + const [scope, name] = this.name?.split('/') ?? [] + const defaultProjectDir = name ?? scope const dirAnswer = await prompt({ type: 'input', name: DIR_PROMOTE_NAME, @@ -118,7 +119,8 @@ export class NewProjectCommand extends Command { mkdirSync(join(process.cwd(), this.dirname!, 'src')) } - const [, binaryName] = this.name!.split('/') + const [s, pkgName] = this.name!.split('/') + const binaryName = pkgName ?? s this.writeFile('Cargo.toml', createCargoContent(this.name!)) this.writeFile('.npmignore', NPMIgnoreFiles)