Skip to content

Commit 0421715

Browse files
author
amazingandyyy
committed
fix
1 parent 492ae92 commit 0421715

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

hooks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const HOOKS = [
2-
'pre-commit',
3-
'pre-push'
2+
'pre-commit',
3+
'pre-push'
44
]
55

6-
module.exports = HOOKS;
6+
module.exports = HOOKS

install.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
const path = require('path')
44
const fs = require('fs')
5-
const HOOKS = require('./hooks');
5+
const HOOKS = require('./hooks')
66

7-
function isCI(env) {
7+
function isCI (env) {
88
// copy from https://github.com/watson/ci-info/blob/2012259979fc38517f8e3fc74daff714251b554d/index.js#L52
99
return env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
1010
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
1111
env.BUILD_NUMBER || // Jenkins, TeamCity
1212
env.RUN_ID || // TaskCluster, dsari
13-
false;
13+
false
1414
}
1515

1616
function installHook (hook) {
1717
const source = path.join(__dirname, 'hook')
1818
const target = path.join('.git', 'hooks', hook)
19-
if(fs.existsSync(source) && fs.existsSync('.git')){
20-
if(isCI(process.env)){
19+
if (fs.existsSync(source) && fs.existsSync('.git')) {
20+
if (isCI(process.env)) {
2121
console.log('[git-hooks]', 'CI Environment detected, skip the git-hooks installation')
2222
} else {
23-
fs.copyFileSync(source, target, 'utf-8');
24-
fs.chmodSync(target, 0o0755);
23+
fs.copyFileSync(source, target, 'utf-8')
24+
fs.chmodSync(target, 0o0755)
2525
}
2626
}
2727
};

uninstall.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/usr/bin/env node
22
const fs = require('fs')
33
const path = require('path')
4-
const HOOKS = require('./hooks');
5-
const hookPathList = HOOKS.map(hook=>path.join('.git', 'hooks', hook));
4+
const HOOKS = require('./hooks')
5+
const hookPathList = HOOKS.map(hook => path.join('.git', 'hooks', hook))
66

77
const generatedByGitHooks = '# git-hooks'
88

9-
function isGeneratedByGitHooks(hook) {
10-
if (fs.existsSync(hook)) {
11-
const d = fs.readFileSync(hook, 'utf-8')
12-
return d.indexOf(generatedByGitHooks) !== -1;
13-
}
14-
return false
9+
function isGeneratedByGitHooks (hook) {
10+
if (fs.existsSync(hook)) {
11+
const d = fs.readFileSync(hook, 'utf-8')
12+
return d.indexOf(generatedByGitHooks) !== -1
13+
}
14+
return false
1515
}
1616

17-
function removeHook(hook) {
18-
fs.unlinkSync(hook)
17+
function removeHook (hook) {
18+
fs.unlinkSync(hook)
1919
}
2020

2121
if (fs.existsSync('.git')) {
22-
hookPathList.filter(isGeneratedByGitHooks).forEach(removeHook)
23-
}else{
24-
console.log('[git-hooks]', 'No .git folder found, skip git-hooks uninstallation')
22+
hookPathList.filter(isGeneratedByGitHooks).forEach(removeHook)
23+
} else {
24+
console.log('[git-hooks]', 'No .git folder found, skip git-hooks uninstallation')
2525
}

0 commit comments

Comments
 (0)