Skip to content

Commit

Permalink
fix: fixed loadConfig with hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 3, 2018
1 parent bfd661a commit 54303a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as Config from '@anycli/config'

import {loadConfig} from './load_config'

/**
* tests a anycli hook
*
Expand All @@ -14,7 +16,7 @@ import * as Config from '@anycli/config'
export default (event?: string, hookOpts: object = {}) => ({
async run(ctx: {config: Config.IConfig, expectation: string}) {
if (!event) throw new Error('no hook provided')
if (!ctx.config) ctx.config = Config.load()
if (!ctx.config) ctx.config = loadConfig().run({} as any)
ctx.expectation = ctx.expectation || `runs ${event} hook`
await ctx.config.runHook(event, hookOpts || {})
}
Expand Down

0 comments on commit 54303a0

Please sign in to comment.