mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +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',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-aspnetcore-spa",
|
||||
"version": "0.2.6",
|
||||
"version": "0.2.7",
|
||||
"description": "Single-Page App templates for ASP.NET Core",
|
||||
"author": "Microsoft",
|
||||
"license": "Apache-2.0",
|
||||
@@ -15,6 +15,7 @@
|
||||
"node-uuid": "^1.4.7",
|
||||
"to-pascal-case": "^1.0.0",
|
||||
"yeoman-generator": "^0.20.2",
|
||||
"yeoman-option-or-prompt": "^1.0.2",
|
||||
"yosay": "^1.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user