Implement universal Git hooks integration#184
Implement universal Git hooks integration#184secret-point wants to merge 1 commit intonetspective-labs:mainfrom
Conversation
| @@ -0,0 +1,108 @@ | |||
|
|
|||
| import { parse } from "https://deno.land/std/flags/mod.ts"; | |||
There was a problem hiding this comment.
Be sure to turn on Deno linting in VS Code, it will remind you that this is not a proper way to reference imports. You should use pinned versions.
| @@ -0,0 +1,108 @@ | |||
|
|
|||
| import { parse } from "https://deno.land/std/flags/mod.ts"; | |||
| import { Command } from "https://deno.land/x/cliffy/command/mod.ts"; | |||
There was a problem hiding this comment.
Be sure to turn on Deno linting in VS Code, it will remind you that this is not a proper way to reference imports. You should use pinned versions.
|
|
||
| for (const [name, handler] of Object.entries(hooks)) { | ||
| const script = `#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env | ||
| import { ${name} } from "https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts"; |
There was a problem hiding this comment.
This means you gave me a PR without local testing. Please never do that again.
| import { parse } from "https://deno.land/std/flags/mod.ts"; | ||
| import { Command } from "https://deno.land/x/cliffy/command/mod.ts"; | ||
|
|
||
| async function initHooks() { |
There was a problem hiding this comment.
add default args like:
initHooks(gitHooksPath = path.join(Deno.cwd(), '.githooks') )
Include anything else that might be optional.
| import { ${name} } from "https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts"; | ||
| await ${name}();`; | ||
|
|
||
| await Deno.writeTextFile(`${gitHooksDir}/${name}`, script, { mode: 0o755 }); |
There was a problem hiding this comment.
use Deno stdlib path module and path.join() not string concatenation for filename.
| } | ||
|
|
||
| if (import.meta.main) { | ||
| await main(); |
There was a problem hiding this comment.
why two if(import.meta.main) blocks?
| await main(); | ||
| } | ||
|
|
||
| if (import.meta.main) { |
There was a problem hiding this comment.
why two if(import.meta.main) blocks?
shah
left a comment
There was a problem hiding this comment.
Also, for true cross-platform utility use the dax module for calling shell scripts if something is not available in Deno.
Changes
Usage
To set up the Git hooks in your project, run:
deno run --allow-write=.githooks https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts initThis command initializes the .githooks directory and configures the hooks to use our Deno-based scripts.