Skip to content

Commit 7f841ff

Browse files
In Yeoman generator, support passing args from command line (e.g., --framework=angular-2)
1 parent 80f740a commit 7f841ff

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

templates/package-builder/src/yeoman/app/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import * as glob from 'glob';
55
const yosay = require('yosay');
66
const toPascalCase = require('to-pascal-case');
77

8+
type YeomanPrompt = (opt: yeoman.IPromptOptions | yeoman.IPromptOptions[], callback: (answers: any) => void) => void;
9+
const optionOrPrompt: YeomanPrompt = require('yeoman-option-or-prompt');
10+
811
const templates = [
912
{ value: 'angular-2', name: 'Angular 2' },
1013
{ value: 'knockout', name: 'Knockout' },
@@ -14,16 +17,18 @@ const templates = [
1417

1518
class MyGenerator extends yeoman.Base {
1619
private _answers: any;
20+
private _optionOrPrompt: YeomanPrompt;
1721

1822
constructor(args: string | string[], options: any) {
1923
super(args, options);
24+
this._optionOrPrompt = optionOrPrompt;
2025
this.log(yosay('Welcome to the ASP.NET Core Single-Page App generator!'));
2126
}
2227

2328
prompting() {
2429
const done = this.async();
2530

26-
this.prompt([{
31+
this._optionOrPrompt([{
2732
type: 'list',
2833
name: 'framework',
2934
message: 'Framework',

templates/package-builder/src/yeoman/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-aspnetcore-spa",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "Single-Page App templates for ASP.NET Core",
55
"author": "Microsoft",
66
"license": "Apache-2.0",
@@ -15,6 +15,7 @@
1515
"node-uuid": "^1.4.7",
1616
"to-pascal-case": "^1.0.0",
1717
"yeoman-generator": "^0.20.2",
18+
"yeoman-option-or-prompt": "^1.0.2",
1819
"yosay": "^1.1.1"
1920
}
2021
}

0 commit comments

Comments
 (0)