Skip to content

Commit a75d174

Browse files
cliffleeSBoudrias
authored andcommittedMay 3, 2017
Better error handling when 'generator-' prefix is specified (#520)
1 parent 6e1a870 commit a75d174

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎lib/cli.js

+14
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ function init() {
135135
return;
136136
}
137137

138+
// More detailed error message
139+
// If users type in generator name with prefix 'generator-'
140+
if (cmd.startsWith('generator-')) {
141+
const generatorName = cmd.replace('generator-', '');
142+
const generatorCommand = chalk.yellow('yo ' + generatorName);
143+
144+
console.log(chalk.red('Installed generators don\'t need the "generator-" prefix.'));
145+
console.log(`In the future, run ${generatorCommand} instead!\n`);
146+
147+
env.run(generatorName, firstCmd.opts);
148+
149+
return;
150+
}
151+
138152
// Note: at some point, nopt needs to know about the generator options, the
139153
// one that will be triggered by the below args. Maybe the nopt parsing
140154
// should be done internally, from the args.

0 commit comments

Comments
 (0)
Please sign in to comment.