Skip to content

Commit d3fdaf4

Browse files
committed
Add verbose option support to log method, and update docs
1 parent fba8187 commit d3fdaf4

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ module.exports = {
4343
var awesomeApiKey = this.readConfig('awesomeApiKey');
4444

4545
// Use the `log` method to generate output consistent with the tree style
46-
// of ember-cli-deploy
47-
this.log('unleashing awesomeness');
46+
// of ember-cli-deploy's verbose output
47+
this.log('output some awesomeness');
48+
this.log('output some red awesomeness', { color: 'red' });
49+
this.log('output this only when verbose option is enabled', { verbose: true });
4850

4951
// Need to do something async? You can return a promise.
5052
// Need to fail out? Throw an error or return a promise which becomes rejected

index.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ var DeployPluginBase = CoreObject.extend({
1212
this.context = context;
1313
this.ui = context.ui;
1414
this.project = context.project;
15-
context.config[this.name] = context.config[this.name] || {}
15+
context.config[this.name] = context.config[this.name] || {};
1616
this.pluginConfig = context.config[this.name];
1717
},
18-
configure: function(context) {
19-
this.log('validating config');
18+
configure: function(/* context */) {
19+
this.log('validating config', { verbose: true});
2020
var defaultProps = Object.keys(this.defaultConfig || {});
2121
defaultProps.forEach(this.applyDefaultConfigProperty.bind(this));
2222
var requiredProps = this.requiredConfig || [];
2323
requiredProps.forEach(this.ensureConfigPropertySet.bind(this));
24-
this.log('config ok');
24+
this.log('config ok', { verbose: true });
2525
},
2626
applyDefaultConfigProperty: function(propertyName){
2727
if (this.pluginConfig[propertyName] === undefined) {
@@ -31,7 +31,7 @@ var DeployPluginBase = CoreObject.extend({
3131
if (typeof description === "function") {
3232
description = "[Function]";
3333
}
34-
this.log('Missing config: `' + propertyName + '`, using default: `' + description + '`', { color: 'yellow' });
34+
this.log('Missing config: `' + propertyName + '`, using default: `' + description + '`', { color: 'yellow', verbose: true });
3535
}
3636
},
3737
ensureConfigPropertySet: function(propertyName){
@@ -49,12 +49,17 @@ var DeployPluginBase = CoreObject.extend({
4949
return configuredValue;
5050
},
5151
log: function(message, opts) {
52-
opts = opts || { color: 'blue' }
53-
opts['color'] = opts['color'] || 'blue';
52+
opts = opts || { color: 'blue' };
53+
opts.color = opts.color || 'blue';
54+
var ui = this.ui;
5455

55-
this.ui.write(blue('| '));
56-
var chalkColor = chalk[opts.color];
57-
this.ui.writeLine(chalkColor('- ' + message));
56+
if (!opts.verbose || (opts.verbose && ui.verbose)) {
57+
if (ui.verbose) {
58+
ui.write(blue('| '));
59+
}
60+
var chalkColor = chalk[opts.color];
61+
ui.writeLine(chalkColor('- ' + message));
62+
}
5863
}
5964
});
6065

0 commit comments

Comments
 (0)