Skip to content

Commit b81d9c1

Browse files
author
Alexander Lisianoi
committed
Add early opt-out if commitplease is being self-installed
1 parent cf43fa8 commit b81d9c1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

install.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ var chalk = require('chalk')
44

55
var options = require('./index.js').getOptions()
66

7-
if (options && options.nohook) {
8-
console.log('commitplease: package.json or .npmrc set to skip hook')
7+
// Is this a self-install? If so, do not copy hooks and quit early
8+
var pkgPath = path.join(options.projectPath, 'package.json')
9+
var pkg = fs.existsSync(pkgPath) && require(pkgPath)
10+
11+
if (pkg && pkg.name && pkg.name === 'commitplease') {
12+
console.log('commitplease: self-install detected, skipping hooks')
13+
process.exit(0)
14+
}
15+
16+
if (options.nohook) {
17+
console.log('commitplease: package.json or .npmrc set to skip hooks')
918
process.exit(0)
1019
}
1120

0 commit comments

Comments
 (0)