Skip to content

Commit

Permalink
refactor(cli): use scoped debug statements in controller generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Delisle committed Jan 3, 2018
1 parent 5e29f01 commit 036065b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/cli/generators/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

'use strict';
const ArtifactGenerator = require('../../lib/artifact-generator');
const debug = require('../../lib/debug')('controller-generator');
const inspect = require('util').inspect;
const utils = require('../../lib/utils');

module.exports = class ControllerGenerator extends ArtifactGenerator {
Expand All @@ -18,6 +20,9 @@ module.exports = class ControllerGenerator extends ArtifactGenerator {
type: 'controller',
outdir: 'src/controllers/',
};
if (debug.enabled) {
debug(`artifactInfo: ${inspect(this.artifactInfo)}`);
}
return super._setupGenerator();
}

Expand All @@ -34,15 +39,20 @@ module.exports = class ControllerGenerator extends ArtifactGenerator {
if (this.shouldExit()) return false;
this.artifactInfo.filename =
utils.kebabCase(this.artifactInfo.name) + '.controller.ts';

if (debug.enabled) {
debug(`Artifact filename set to: ${this.artifactInfo.filename}`);
}
// renames the file
this.fs.move(
this.destinationPath(this.artifactInfo.outdir + 'controller-template.ts'),
this.destinationPath(
this.artifactInfo.outdir + this.artifactInfo.filename
),
{globOptions: {dot: true}}
const source = this.destinationPath(
this.artifactInfo.outdir + 'controller-template.ts'
);
const dest = this.destinationPath(
this.artifactInfo.outdir + this.artifactInfo.filename
);
if (debug.enabled) {
debug(`Copying artifact to: ${dest}`);
}
this.fs.move(source, dest, {globOptions: {dot: true}});
return;
}

Expand Down

0 comments on commit 036065b

Please sign in to comment.