From e5ead8d9477869e5175db68f7283bc0afe889ed5 Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Fri, 22 Apr 2022 15:41:48 +0800 Subject: [PATCH] =?UTF-8?q?create=20=E6=94=AF=E6=8C=81=20-d=20--dev=20?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/create.d.ts | 2 +- lib/create.js | 4 ++-- lib/index.js | 4 ++-- src/create.ts | 5 ++--- src/index.ts | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/create.d.ts b/lib/create.d.ts index e50fb0c..d5dc5c5 100644 --- a/lib/create.d.ts +++ b/lib/create.d.ts @@ -1 +1 @@ -export default function create(dirName: string, env: string): Promise; +export default function create(dirName: string, cmd: any): Promise; diff --git a/lib/create.js b/lib/create.js index 9dca358..e7f31ae 100644 --- a/lib/create.js +++ b/lib/create.js @@ -58,7 +58,7 @@ async function getMiniVersion() { }); return versionsSort[0]['sdkVer']; } -async function create(dirName, env) { +async function create(dirName, cmd) { const nameOption = { type: 'input', name: 'name', @@ -66,7 +66,7 @@ async function create(dirName, env) { default: dirName, }; prompt.unshift(nameOption); - const isDev = env === 'dev' || env === 'development'; + const isDev = cmd.dev ? true : false; const { name, version, description } = await inquirer_1.default.prompt(prompt); // 获取微信小程序稳定基础版本库 const miniVersion = await getMiniVersion(); diff --git a/lib/index.js b/lib/index.js index 661cd8f..5c7bc12 100755 --- a/lib/index.js +++ b/lib/index.js @@ -56,9 +56,9 @@ commander_1.default .description('build we chat mp of build on demand') .action(build_1.default); commander_1.default - .command('create [env]') + .command('create ') .usage('') - // .option('-e, --env ', 'A env') + .option('-d, --dev', 'dev') .description(`create a new project powered by ${config_1.CLI_NAME}`) .action(create_1.default); // output help information on unknown commands diff --git a/src/create.ts b/src/create.ts index 24bfb02..ca20fb3 100644 --- a/src/create.ts +++ b/src/create.ts @@ -90,7 +90,7 @@ async function getMiniVersion() { return versionsSort[0]['sdkVer']; } -export default async function create(dirName: string, env: string) { +export default async function create(dirName: string, cmd: any) { const nameOption = { type: 'input', name: 'name', @@ -98,8 +98,7 @@ export default async function create(dirName: string, env: string) { default: dirName, }; prompt.unshift(nameOption); - - const isDev = env === 'dev' || env === 'development'; + const isDev = cmd.dev ? true : false; const { name, version, description }: PromptInput = await inquirer.prompt( prompt diff --git a/src/index.ts b/src/index.ts index 02e8e5e..9a8e5a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -58,9 +58,9 @@ program .description('build we chat mp of build on demand') .action(build); program - .command('create [env]') + .command('create ') .usage('') - // .option('-e, --env ', 'A env') + .option('-d, --dev', 'dev') .description(`create a new project powered by ${CLI_NAME}`) .action(create); // output help information on unknown commands