@@ -4,6 +4,7 @@ var path = require('path')
4
4
var chalk = require ( 'chalk' )
5
5
var Git = require ( 'git-tools' )
6
6
7
+ var endsWith = require ( 'ends-with' )
7
8
var objectAssign = require ( 'object-assign' )
8
9
9
10
var validate = require ( './lib/validate' )
@@ -12,18 +13,21 @@ var defaults = require('./lib/defaults')
12
13
13
14
// Need to find the path to the project that is installing
14
15
// commitplease. Previously, process.cwd() made the job easy but its
15
- // output changed with node v8.1.2
16
+ // output changed with node v8.1.2 (at least compared to 7.10.0)
16
17
function getProjectPath ( ) {
17
18
// Use the fact that npm will inject a path that ends with
18
- // commitplease/node_modules/.bin into PATH
19
+ // commitplease/node_modules/.bin into process.env. PATH
19
20
var p = process . env . PATH . split ( ':' ) . filter (
20
21
function ( p ) {
21
- return p . endsWith ( path . join ( 'commitplease' , 'node_modules' , '.bin' ) )
22
+ return endsWith ( p , path . join ( 'commitplease' , 'node_modules' , '.bin' ) )
22
23
}
23
24
)
24
25
25
26
if ( p . length !== 1 ) {
26
27
console . error ( chalk . red ( 'Failed to find project path\n' ) )
28
+
29
+ // Just leave with zero so as not to interrupt install
30
+ process . exit ( 0 )
27
31
}
28
32
29
33
// Removing suffix node_modules/commitplease/node_modules/.bin will
@@ -37,8 +41,6 @@ function getProjectPath () {
37
41
function getOptions ( ) {
38
42
var projectPath = getProjectPath ( )
39
43
40
- console . log ( projectPath )
41
-
42
44
var pkg = path . join ( projectPath , 'package.json' )
43
45
var npm = path . join ( projectPath , '.npmrc' )
44
46
0 commit comments