create 支持 -d --dev 表示测试

This commit is contained in:
Wang Kejun 2022-04-22 15:41:48 +08:00
parent d3edff0578
commit e5ead8d947
5 changed files with 9 additions and 10 deletions

2
lib/create.d.ts vendored
View File

@ -1 +1 @@
export default function create(dirName: string, env: string): Promise<void>;
export default function create(dirName: string, cmd: any): Promise<void>;

View File

@ -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();

View File

@ -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 <name> [env]')
.command('create <name>')
.usage('<name>')
// .option('-e, --env <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

View File

@ -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

View File

@ -58,9 +58,9 @@ program
.description('build we chat mp of build on demand')
.action(build);
program
.command('create <name> [env]')
.command('create <name>')
.usage('<name>')
// .option('-e, --env <env>', 'A env')
.option('-d, --dev', 'dev')
.description(`create a new project powered by ${CLI_NAME}`)
.action(create);
// output help information on unknown commands