Skip to content

Commit

Permalink
Prevent running on existing project and force running page sub genera…
Browse files Browse the repository at this point in the history
…tor on existing project (#379)

* Fix check of existing project when using page subgenerator

* When creating new project check if project exists in current directory

* Update error text
  • Loading branch information
jakub300 authored and luboskmetko committed Jun 11, 2018
1 parent d5a6e26 commit 40cdf46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 16 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ module.exports = class extends Generator {
super(args, opts);
}

initializing() {
if (this.config.existed) {
this.log('A Chisel project already exists in this folder.');
this.log(
'If you are trying to setup an existing project, check out the' +
' documentation at https://www.getchisel.co/docs/setup/'
);
this.log(
'If the process of generating project was interrupted and you would' +
' like to continue, we recommend cleaning up the directory and' +
' starting again.'
);
process.exit(1);
}
}

prompting() {
const done = this.async();

Expand Down
7 changes: 3 additions & 4 deletions generators/page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ module.exports = class extends Generator {
* @public
*/
initializing() {
try {
this.configuration = this.config.get('config');
} catch (ex) {
if(!this.config.existed) {
this.log('You need to run this generator in a project directory.');
process.exit();
process.exit(1);
}
this.configuration = this.config.get('config');
this.pages = this.config.get('pages');
}

Expand Down

0 comments on commit 40cdf46

Please sign in to comment.