diff --git a/packages/cli/generators/controller/index.js b/packages/cli/generators/controller/index.js index d16b4cb5a9e0..8a20f57465b7 100644 --- a/packages/cli/generators/controller/index.js +++ b/packages/cli/generators/controller/index.js @@ -224,19 +224,5 @@ module.exports = class ControllerGenerator extends ArtifactGenerator { async end() { await super.end(); - if (this.shouldExit()) return false; - // logs a message if there is no file conflict - if ( - this.conflicter.generationStatus[this.artifactInfo.filename] !== 'skip' && - this.conflicter.generationStatus[this.artifactInfo.filename] !== - 'identical' - ) { - this.log(); - this.log( - 'Controller %s is now created in src/controllers/', - this.artifactInfo.name, - ); - this.log(); - } } }; diff --git a/packages/cli/lib/artifact-generator.js b/packages/cli/lib/artifact-generator.js index 1cf9f83521e0..f4e94a420f3b 100644 --- a/packages/cli/lib/artifact-generator.js +++ b/packages/cli/lib/artifact-generator.js @@ -110,16 +110,36 @@ module.exports = class ArtifactGenerator extends BaseGenerator { const success = super.end(); if (!success) return false; - // Update `index.ts` - await makeIndex(this.artifactInfo.outDir, { - prefix: `${this.artifactInfo.type}`, + let generationStatus = true; + // Check all files being generated to ensure they succeeded + Object.entries(this.conflicter.generationStatus).forEach(([key, val]) => { + if (val === 'skip' || val === 'identical') generationStatus = false; }); - const relPath = path.relative( - this.destinationPath(), - this.artifactInfo.outDir, - ); - this.log(chalk.green(' update'), `${relPath}/index.ts`); - return true; + if (generationStatus) { + // Update `index.ts` + await makeIndex(this.artifactInfo.outDir, { + prefix: `${this.artifactInfo.type}`, + }); + + // Relative path of output directory + const relPath = path.relative( + this.destinationPath(), + this.artifactInfo.outDir, + ); + + // Output for users + this.log(chalk.green(' update'), `${relPath}/index.ts`); + this.log(); + this.log( + utils.toClassName(this.artifactInfo.type), + chalk.yellow(this.artifactInfo.name), + 'is now created in', + `${relPath}/`, + ); + this.log(); + } + + return false; } };