Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue yeoman/yo#518 #81

Merged
merged 3 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const escapeStrRe = require('escape-string-regexp');
const untildify = require('untildify');
const memFs = require('mem-fs');
const debug = require('debug')('yeoman:environment');
const isScoped = require('is-scoped');
const Store = require('./store');
const resolver = require('./resolver');
const TerminalAdapter = require('./adapter');
Expand Down Expand Up @@ -338,13 +339,21 @@ class Environment extends EventEmitter {
const Generator = this.get(namespace);

if (typeof Generator !== 'function') {
let generatorHint = '';
if (isScoped(namespace)) {
const splitName = namespace.split('/');
generatorHint = `${splitName[0]}/generator-${splitName[1]}`;
} else {
generatorHint = `generator-${namespace}`;
}

return this.error(
new Error(
chalk.red('You don\'t seem to have a generator with the name “' + namespace + '” installed.') + '\n' +
'But help is on the way:\n\n' +
'You can see available generators via ' +
chalk.yellow('npm search yeoman-generator') + ' or via ' + chalk.yellow('http://yeoman.io/generators/') + '. \n' +
'Install them with ' + chalk.yellow('npm install generator-' + namespace) + '.\n\n' +
'Install them with ' + chalk.yellow(`npm install ${generatorHint}`) + '.\n\n' +
'To see all your installed generators run ' + chalk.yellow('yo') + ' without any arguments. ' +
'Adding the ' + chalk.yellow('--help') + ' option will also show subgenerators. \n\n' +
'If ' + chalk.yellow('yo') + ' cannot find the generator, run ' + chalk.yellow('yo doctor') + ' to troubleshoot your system.'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"globby": "^6.1.0",
"grouped-queue": "^0.3.0",
"inquirer": "^3.0.1",
"is-scoped": "^1.0.0",
"lodash": "^4.11.1",
"log-symbols": "^1.0.1",
"mem-fs": "^1.1.0",
Expand Down
7 changes: 7 additions & 0 deletions test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,13 @@ describe('Environment', () => {
it('returns the generator', function () {
assert.ok(this.env.run('stub:run') instanceof Generator);
});

it('correctly append scope in generator hint', function () {
this.env.on('error', err => {
assert.ok(err.message.indexOf('@dummyscope/generator-package') >= 0);
});
this.env.run('@dummyscope/package');
});
});

describe('#registerModulePath()', () => {
Expand Down