Skip to content

Commit

Permalink
feat(cli): add hooks command
Browse files Browse the repository at this point in the history
  • Loading branch information
umbopepato committed Jun 30, 2020
1 parent 53a6cf4 commit 561a4fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/cli/commands/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BaseCommand } from "../../../deps.ts";
import { ConfigData } from "../../load_config.ts";
import { runScript } from "../../run_script.ts";
import { HookType } from "../types/hook_type.ts";
import {installGitHooks} from '../../git_hooks.ts';

export class HooksCommand extends BaseCommand {
constructor(private configData: ConfigData | null) {
super();
this.description("Git hooks")
.type("hook", new HookType())
.command("run <hook:hook> [args...]")
.description("Run a git hook")
.useRawArgs()
.action(async (_, hook: string, ...args: string[]) => {
await runHook(this.configData, hook, args);
})
.command("install")
.description("Install git hooks")
.action(() => installGitHooks(this.configData.cwd));
}
}
8 changes: 8 additions & 0 deletions src/cli/types/hook_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { StringType } from "../../../deps.ts";
import { hooks } from "../../git_hooks.ts";

export class HookType extends StringType {
complete(): string[] {
return hooks;
}
}

0 comments on commit 561a4fd

Please sign in to comment.