diff --git a/bin/cli/cli.js b/bin/cli/cli.js index 7921da776..732fc1133 100644 --- a/bin/cli/cli.js +++ b/bin/cli/cli.js @@ -15,7 +15,7 @@ function getArgs (startIndex = 1) { args[longArgFlag] = longArgValue; // flags } else if (arg[0] === '-') { - const flags = arg.slice(1, arg.length).split(''); + const flags = arg.slice(1, arg.length); args[flags] = true; } }); @@ -27,10 +27,12 @@ const cmds = new Map([ ['worker', workerCmd], ]); -const startIndex = process.argv.findIndex(argv => argv === 'fui-cli'); +const baseCmd = 'fui-cli'; + +const startIndex = process.argv.findIndex(argv => argv.indexOf(baseCmd) !== -1); if (startIndex === -1) { - throw new Error('commad not found'); + throw new Error(`Command ${baseCmd} not found in args`); } const cmd = process.argv[startIndex + 1]; @@ -38,5 +40,5 @@ const cmd = process.argv[startIndex + 1]; if (cmds.has(cmd)) { cmds.get(cmd)?.exec(getArgs(startIndex + 2)); } else { - throw new Error('命令不存在'); + throw new Error(`Command ${cmd} not supported`); } diff --git a/bin/cli/worker/cli.worker.js b/bin/cli/worker/cli.worker.js index 13ad48a5d..0c086db08 100644 --- a/bin/cli/worker/cli.worker.js +++ b/bin/cli/worker/cli.worker.js @@ -21,11 +21,11 @@ function scanAndCreate(structure, root = process.cwd()) { module.exports = { exec: async args => { if (!args.init) { - throw new Error('command not found'); + throw new Error(`Command init not found in args`); } if (!args.name) { - throw new Error('fileName not found'); + throw new Error('Command --name=... not found in args'); } const name = args.name;