Skip to content

Commit 874e3c8

Browse files
committed
add PREFER_APPEND_FILE_SYNC env
1 parent 0433a04 commit 874e3c8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

simple-git-hooks.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ function _setHook(hook, command, projectRoot=process.cwd()) {
201201
fs.mkdirSync(normalizedHookDirectory)
202202
}
203203

204-
fs.writeFileSync(hookPath, hookCommand)
204+
// use PREFER_APPEND_FILE_SYNC env to append hook command into file
205+
if (['1', 'true'].includes(process.env.PREFER_APPEND_FILE_SYNC)) {
206+
fs.appendFileSync(hookPath, hookCommand)
207+
} else {
208+
fs.writeFileSync(hookPath, hookCommand)
209+
}
205210
fs.chmodSync(hookPath, 0o0755)
206211

207212
console.info(`[INFO] Successfully set the ${hook} with command: ${command}`)

0 commit comments

Comments
 (0)