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

Commit

Permalink
attach plugin to command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 3, 2018
1 parent 06ba8fd commit 5ea1044
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ export class Config extends Plugin.Plugin implements IConfig {

async runCommand(id: string, argv: string[] = []) {
debug('runCommand %s %o', id, argv)
const command = this.findCommand(id, {must: true})
await this.runHook('prerun', {command, argv})
await command.load().run(argv, this)
const command = this.findCommand(id, {must: true}).load()
await this.runHook('prerun', {Command: command, argv})
await command.run(argv, this)
}

scopedEnvVar(k: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Config from '.'
export interface Hooks {
init: {argv: string[]}
prerun: {
command: Config.Command
Command: Config.Command.Class
argv: string[]
}
update: {}
Expand Down
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class Plugin implements IPlugin {
debug('require', p)
const cmd = search(require(p))
cmd.id = id
cmd.plugin = this
return cmd
}

Expand Down

0 comments on commit 5ea1044

Please sign in to comment.