Yeoman generator: how do I access user supplied options? -
Yeoman generator: how do I access user supplied options? -
i'm building yeoman generator. prompt user name project this:
simplesitegenerator.prototype.askfor = function askfor() { var cb = this.async(); console.log(this.yeoman); var prompts = [{ name: 'sitename', message: 'what want phone call site?' }]; this.prompt(prompts, function (props) { this.sitename = props.sitename; cb(); }.bind(this)); };
further on, build file system:
simplesitegenerator.prototype.app = function app() { this.mkdir( 'app'); this.mkdir('app/templates'); this.mkdir( 'img');
i'd build filesystem within directory given same name project. how user-supplied alternative , pass app ?
you need create empty global variable, assign value of users reply so
var projectfoldername = ''; this.prompt(prompts, function (props) { this.sitename = props.sitename; projectfoldername = props.sitename; cb(); }.bind(this));
then inject variable build path string via concatenation so
simplesitegenerator.prototype.app = function app() { this.mkdir( 'app/' + projectfoldername); this.mkdir('app/templates'); this.mkdir( 'img'); }
yeoman yeoman-generator
Comments
Post a Comment