Skip to content

Commit fd32c22

Browse files
authoredMay 21, 2023
feat: add new hook file to staging with executable bit (#1243)
1 parent 7543615 commit fd32c22

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎src/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cp = require('child_process')
22
import fs = require('fs')
33
import p = require('path')
4+
import os = require('os')
45

56
// Logger
67
const l = (msg: string): void => console.log(`husky - ${msg}`)
@@ -80,6 +81,19 @@ ${cmd}
8081
)
8182

8283
l(`created ${file}`)
84+
85+
if (os.type() === 'Windows_NT') {
86+
l(
87+
`Due to a limitation on Windows systems, the executable bit of the file cannot be set without using git.
88+
To fix this, the file ${file} has been automatically moved to the staging environment and the executable bit has been set using git.
89+
Note that, if you remove the file from the staging environment, the executable bit will be removed.
90+
You can add the file back to the staging environment and include the executable bit using the command 'git update-index -add --chmod=+x ${file}'.
91+
If you have already committed the file, you can add the executable bit using 'git update-index --chmod=+x ${file}'.
92+
You will have to commit the file to have git keep track of the executable bit.`,
93+
)
94+
95+
git(['update-index', '--add', '--chmod=+x', file])
96+
}
8397
}
8498

8599
// Create a hook if it doesn't exist or append command to it

0 commit comments

Comments
 (0)
Please sign in to comment.