mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +00:00
In Yeoman generator, support passing args from command line (e.g., --framework=angular-2)
This commit is contained in:
@@ -5,6 +5,9 @@ import * as glob from 'glob';
|
||||
const yosay = require('yosay');
|
||||
const toPascalCase = require('to-pascal-case');
|
||||
|
||||
type YeomanPrompt = (opt: yeoman.IPromptOptions | yeoman.IPromptOptions[], callback: (answers: any) => void) => void;
|
||||
const optionOrPrompt: YeomanPrompt = require('yeoman-option-or-prompt');
|
||||
|
||||
const templates = [
|
||||
{ value: 'angular-2', name: 'Angular 2' },
|
||||
{ value: 'knockout', name: 'Knockout' },
|
||||
@@ -14,16 +17,18 @@ const templates = [
|
||||
|
||||
class MyGenerator extends yeoman.Base {
|
||||
private _answers: any;
|
||||
private _optionOrPrompt: YeomanPrompt;
|
||||
|
||||
constructor(args: string | string[], options: any) {
|
||||
super(args, options);
|
||||
this._optionOrPrompt = optionOrPrompt;
|
||||
this.log(yosay('Welcome to the ASP.NET Core Single-Page App generator!'));
|
||||
}
|
||||
|
||||
prompting() {
|
||||
const done = this.async();
|
||||
|
||||
this.prompt([{
|
||||
this._optionOrPrompt([{
|
||||
type: 'list',
|
||||
name: 'framework',
|
||||
message: 'Framework',
|
||||
|
||||
Reference in New Issue
Block a user