Skip to content

Commit

Permalink
fix: await yeoman generators (#926)
Browse files Browse the repository at this point in the history
* fix: await yeoman generators

* chore: satisfy linter
  • Loading branch information
mdonnalley committed Jul 27, 2022
1 parent fb5da96 commit da5a4d2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/command-base.ts
Expand Up @@ -2,15 +2,16 @@ import {Command} from '@oclif/core'
import {createEnv} from 'yeoman-environment'

export default abstract class CommandBase extends Command {
protected generate(type: string, generatorOptions: Record<string, unknown> = {}): void {
protected async generate(type: string, generatorOptions: Record<string, unknown> = {}): Promise<void> {
const env = createEnv()

env.register(
require.resolve(`./generators/${type}`),
`oclif:${type}`,
)

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
env.run(`oclif:${type}`, generatorOptions)
await env.run(`oclif:${type}`, generatorOptions)
}
}
2 changes: 1 addition & 1 deletion src/commands/generate.ts
Expand Up @@ -13,7 +13,7 @@ This will clone the template repo 'oclif/hello-world' and update package propert
async run(): Promise<void> {
const {args} = await this.parse(Generate)

super.generate('cli', {
await super.generate('cli', {
name: args.name,
force: true,
})
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate/command.ts
Expand Up @@ -15,7 +15,7 @@ export default class GenerateCommand extends CommandBase {
async run(): Promise<void> {
const {args, flags} = await this.parse(GenerateCommand)

super.generate('command', {
await super.generate('command', {
name: args.name,
force: flags.force,
})
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate/hook.ts
Expand Up @@ -16,7 +16,7 @@ export default class GenerateHook extends CommandBase {
async run(): Promise<void> {
const {args, flags} = await this.parse(GenerateHook)

super.generate('hook', {
await super.generate('hook', {
name: args.name,
event: flags.event,
force: flags.force,
Expand Down

0 comments on commit da5a4d2

Please sign in to comment.