diff --git a/generators/app/index.js b/generators/app/index.js index 326886c3..bb59b4b5 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -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(); diff --git a/generators/page/index.js b/generators/page/index.js index 5ff324a7..008a262a 100644 --- a/generators/page/index.js +++ b/generators/page/index.js @@ -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'); }