Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: husky #367

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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