Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: let command call the init hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 3, 2018
1 parent 60d52e1 commit aa67851
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export class Config extends Plugin.Plugin implements IConfig {
}

async runCommand(id: string, argv: string[] = []) {
await this.runHook('init', {id})
debug('runCommand %s %o', id, argv)
const cmd = this.findCommand(id, {must: true}).load()
await this.runHook('prerun', {Command: cmd, argv})
Expand Down
11 changes: 9 additions & 2 deletions test/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ describe('typescript', () => {

withConfig
.stdout()
.it('runs ts command init, and prerun hooks', async ctx => {
.it('runs ts command and prerun hooks', async ctx => {
await ctx.config.runCommand('foo:bar:baz')
expect(ctx.stdout).to.equal('running ts init hook\nrunning ts prerun hook\nit works!\n')
expect(ctx.stdout).to.equal('running ts prerun hook\nit works!\n')
})

withConfig
.stdout()
.it('runs init hook', async ctx => {
await ctx.config.runHook('init', {id: 'foo'})
expect(ctx.stdout).to.equal('running ts init hook\n')
})
})

0 comments on commit aa67851

Please sign in to comment.