[yeoman-generator] add async and env.adapter (#35115)

* [yeoman-generator] add async and env.adapter

* [yeoman-generator] fix imports
This commit is contained in:
Devid Farinelli
2019-04-30 21:44:16 -07:00
committed by Wesley Wigham
parent 3fa1a06771
commit 5fd22abff1
2 changed files with 13 additions and 2 deletions
+6 -1
View File
@@ -6,6 +6,7 @@
// Joshua Cherry <https://github.com/tasadar2>
// Arthur Corenzan <https://github.com/haggen>
// Richard Lea <https://github.com/chigix>
// Devid Farinelli <https://github.com/misterdev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -87,7 +88,10 @@ declare class Generator extends EventEmitter {
constructor(args: string|string[], options: {});
env: {
error(...e: Error[]): void
error(...e: Error[]): void;
adapter: {
promptModule: inquirer.PromptModule;
};
};
args: {};
resolved: string;
@@ -114,6 +118,7 @@ declare class Generator extends EventEmitter {
// actions/help mixin
argumentsHelp(): string;
async(): () => {};
desc(description: string): this;
help(): string;
optionsHelp(): string;
@@ -1,13 +1,18 @@
import Base = require('yeoman-generator');
import { Questions, Answers } from 'yeoman-generator';
import { EventEmitter } from 'events';
import * as inquirer from 'inquirer';
class MyES2015Generator extends Base {}
const generator = new MyES2015Generator(['arg1', 'arg2'], { opt1: 'foo', opt2: 3, opt3: false });
const eventEmitter: EventEmitter = generator;
const env: {} = generator.env;
const env: {
adapter: {
promptModule: inquirer.PromptModule;
}
} = generator.env;
const args: {} = generator.args;
const resolved: string = generator.resolved;
const description: string = generator.description;
@@ -41,6 +46,7 @@ generator.argument('arg4', {
});
const argsHelp = generator.argumentsHelp();
generator.async();
async function install() {
generator.installDependencies();