Skip to content

Commit

Permalink
improve the official generator detection
Browse files Browse the repository at this point in the history
Had to hardcode the list since it's impossible to detect as people keeps forking ours and not updating the `author` and `repository` fields in package.json... t(ಠ益ಠt)

Shouldn't matter though as we're not going to make any more official generators.
  • Loading branch information
sindresorhus committed Jul 26, 2015
1 parent 8f8c376 commit 06f98c1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions lib/routes/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ var npmKeyword = require('npm-keyword');
var packageJson = require('package-json');
var got = require('got');

var OFFICIAL_GENERATORS = [
'generator-angular',
'generator-backbone',
'generator-bootstrap',
'generator-chrome-extension',
'generator-chromeapp',
'generator-commonjs',
'generator-generator',
'generator-gruntplugin',
'generator-gulp-webapp',
'generator-jasmine',
'generator-jquery',
'generator-karma',
'generator-mobile',
'generator-mocha',
'generator-node',
'generator-polymer',
'generator-webapp'
];

module.exports = function (app) {
app.insight.track('yoyo', 'install');

Expand Down Expand Up @@ -76,22 +96,14 @@ function searchMatchingGenerators(app, term, cb) {
});
}

function isYeomanPackage(pkg) {
if (pkg.author && pkg.author.name) {
return pkg.author.name.indexOf('Yeoman') !== -1;
}

return false;
}

function fetchGeneratorInfo(generator, cb) {
packageJson(generator.name, function (err, pkg) {
if (err) {
cb(err);
return;
}

var official = isYeomanPackage(pkg);
var official = OFFICIAL_GENERATORS.indexOf(pkg.name) !== -1;
var mustache = official ? chalk.green(' ' + figures.mustache + ' ') : '';

cb(null, {
Expand Down

0 comments on commit 06f98c1

Please sign in to comment.