microsoft / generator-docker

Yeoman generator for Docker
Other
346 stars 69 forks source link

Allow generator-docker to be called with options, and prevent prompt #123

Open dnoliver opened 7 years ago

dnoliver commented 7 years ago

To improve composability, add options to the generator code.

  1. use the options as default properties
  2. do not prompt for parameters when an option is already defined

i.e:

constructor: function () {
  yeoman.Base.apply(this, arguments);

  this.option('boilerplate', {
      type: Boolean,
      required: false,
      desc: 'Include Boilerplate'
  });
},

initializing: function () {
  this.props = {
      boilerplate: Boolean(this.options.boilerplate)
  };
},

prompting: function () {
  var prompts = [{
      type: 'confirm',
      name: 'boilerplate',
      message: 'Include Boilerplate',
      default: true,,
      when: this.options.boilerplate === undefined
    }];

  return this.prompt(prompts)
      .then(function (props) {
        this.props = extend(this.props, props);
      }.bind(this));
}
dnoliver commented 7 years ago

I can contribute with this feature