Skip to content

Commit

Permalink
tips
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYCL committed Dec 2, 2020
1 parent 9afb7c6 commit fa4c2cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

36 changes: 18 additions & 18 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import chalk from "chalk";

function parseArgumentsIntoOptions(rawArgs) {
const args = arg(
{
'--git': Boolean,
'--yes': Boolean,
'--install': Boolean,
'--version':Boolean,
'-g': '--git',
'-y': '--yes',
'-i': '--install',
'-v':'--version',
},
{
argv: rawArgs.slice(2),
}
{
'--git': Boolean,
'--yes': Boolean,
'--install': Boolean,
'--version':Boolean,
'-g': '--git',
'-y': '--yes',
'-i': '--install',
'-v':'--version',
},
{
argv: rawArgs.slice(2),
}
);
return {
skipPrompts: args['--yes'] || false,
Expand All @@ -31,8 +31,8 @@ function parseArgumentsIntoOptions(rawArgs) {
async function promptForMissingOptions(options) {
const defaultTemplate = 'app';
if(options.version){
console.log('% cli version:', chalk.green.bold(require('../package.json').version));
process.exit()
console.log('% cli version:', chalk.green.bold(require('../package.json').version));
process.exit()
}
if (options.skipPrompts) {
return {
Expand All @@ -56,7 +56,7 @@ async function promptForMissingOptions(options) {
questions.push({
type: 'input',
name: 'port',
message: '请输入开发环境端口<9505>',
message: '请输入开发环境端口<9505>:',
validate:(value)=>{
if(isNaN(value)){
return '必须是数字'
Expand All @@ -71,15 +71,15 @@ async function promptForMissingOptions(options) {
questions.push({
type: 'input',
name: 'base',
message: '请输入子模块注册base名',
message: '请输入子模块注册base名:',
});
}

if (!options.git) {
questions.push({
type: 'confirm',
name: 'git',
message: '初始化git',
message: '初始化git?',
default: false,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export async function createProject(options) {
try {
await access(templateDir, fs.constants.R_OK);
} catch (err) {
console.error('%s 无效模版名', chalk.red.bold('ERROR'));
console.error(chalk.red.bold('ERROR:'),err);
process.exit(1);
}

Expand Down

0 comments on commit fa4c2cb

Please sign in to comment.