Skip to content

Commit

Permalink
feat(hooks): add githook typing
Browse files Browse the repository at this point in the history
  • Loading branch information
umbopepato committed Oct 30, 2020
1 parent a50748c commit 02abd70
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/merge_params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AllowFlags, FlagsObject, ScriptOptions } from "./scripts_config.ts";
import { FlagsObject, ScriptOptions } from "./scripts_config.ts";

export function mergeParams(
childParams: ScriptOptions,
Expand Down
3 changes: 1 addition & 2 deletions src/normalize_script.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
isParallelScripts,
isScriptObject,
ParallelScripts,
ScriptDefinition,
ScriptOptions,
} from "./scripts_config.ts";
import { Command, isParallel, ParallelCommands } from "./command.ts";
import { mergeParams } from "./merge_params.ts";
import { isParallelScripts, isScriptObject } from "./util.ts";

/**
* Normalizes a script definition to a list of `Command` objects
Expand Down
6 changes: 2 additions & 4 deletions src/run_script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { bold } from "../deps.ts";
import { normalizeScript } from "./normalize_script.ts";
import { resolveShell } from "./resolve_shell.ts";
import { runCommands } from "./run_commands.ts";
import { validateConfigData } from "./validate_config_data.ts";
import { validateScript } from "./validate_script.ts";

export async function runScript(
configData: ConfigData | null,
configData: ConfigData,
script: string,
additionalArgs: string[] = [],
) {
validateConfigData(configData);
const { cwd, config } = configData as ConfigData;
const { cwd, config } = configData;
if (script == null || script.length < 1) {
printScriptsInfo(config);
Deno.exit();
Expand Down
25 changes: 19 additions & 6 deletions src/scripts_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface ScriptObject extends ScriptOptions {
/**
* A git hook where to execute this command
*/
githook?: string;
githook?: GitHook;
}

/**
Expand Down Expand Up @@ -206,8 +206,21 @@ export type FlagsObject = Record<string, any>;

export type EnvironmentVariables = Record<string, string>;

export const isScriptObject = (script: object): script is ScriptObject =>
"cmd" in script;

export const isParallelScripts = (script: object): script is ParallelScripts =>
"pll" in script;
export type GitHook =
| "applypatch-msg"
| "pre-applypatch"
| "post-applypatch"
| "pre-commit"
| "pre-merge-commit"
| "prepare-commit-msg"
| "commit-msg"
| "post-commit"
| "pre-rebase"
| "post-checkout"
| "post-merge"
| "pre-push"
| "post-update"
| "push-to-checkout"
| "pre-auto-gc"
| "post-rewrite"
| "sendemail-validate";

0 comments on commit 02abd70

Please sign in to comment.