Skip to content

Commit a3716c8

Browse files
committed
Throw an error if the project name is the same as one of the dependencies (#117)
1 parent 3767c49 commit a3716c8

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

  • packages/generator-feathers/generators/app

packages/generator-feathers/generators/app/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,24 @@ module.exports = generators.Base.extend({
389389
'request'
390390
];
391391

392-
this.npmInstall(this.dependencies, { save: true });
393-
394392
if(this.props.babel) {
395393
devDependencies.push('babel-cli', 'babel-core', 'babel-preset-es2015');
396394
}
395+
396+
this.dependencies.concat(devDependencies).forEach(function(dependency) {
397+
var separatorIndex = dependency.indexOf('@');
398+
var end = separatorIndex !== -1 ? separatorIndex : dependency.length;
399+
var dependencyName = dependency.substring(0, end);
400+
401+
// Throw an error if the project name is the same as one of the dependencies
402+
if(dependencyName === this.props.name) {
403+
this.log.error('Your project can not be named ' + this.props.name + ' because the ' +
404+
dependency + ' package will be installed as dependency.');
405+
process.exit(1);
406+
}
407+
}.bind(this));
397408

409+
this.npmInstall(this.dependencies, { save: true });
398410
this.npmInstall(devDependencies, { saveDev: true});
399411
}
400412
},

0 commit comments

Comments
 (0)