Skip to content

Commit

Permalink
feat: husky update
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar authored Oct 25, 2024
1 parent 1ce9ec5 commit eb38483
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn todos && git add TODO.md
yarn prettier --write TODO.md && git add TODO.md
yarn doctoc && git add README.md
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
],
"scripts": {
"build": "yarn workspaces foreach --all --topological --verbose run build",
"build:watch": "yarn workspaces foreach --all --parallel --jobs unlimited --interlaced run build:watch",
"build:clean": "yarn workspaces foreach --all --topological --verbose run build:clean",
"build:watch": "yarn workspaces foreach --all --parallel --jobs unlimited --interlaced run build:watch",
"doctoc": "doctoc README.md",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check --ignore-unknown .",
Expand Down
15 changes: 4 additions & 11 deletions packages/plugins/src/husky/husky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ export async function addPreCommitHookCommand({
return;
}

await exec("yarn", ["husky", "add", PRE_COMMIT_FILENAME, `"${command}"`], {
cwd: directory,
await setPreCommitHookCommands({
directory,
commands: [...(await getPreCommitHookCommands({ directory })), command],
});
}

Expand All @@ -139,15 +140,7 @@ export async function removePreCommitHookCommand({
(line) => line !== command,
);

if (newCommands.length === 2) {
/**
* We're left with only these lines:
*
* ```
* #!/usr/bin/env sh
* . "$(dirname -- "$0")/_/husky.sh"
* ```
*/
if (newCommands.length === 0) {
await removeFile({ path: getPreCommitHookPath({ directory }) });
return;
}
Expand Down

0 comments on commit eb38483

Please sign in to comment.