Skip to content

Commit 67f5ab1

Browse files
author
Alexander Lisianoi
committed
Add ends-with dependency to make it work on node 0.12
1 parent d7629e1 commit 67f5ab1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var path = require('path')
44
var chalk = require('chalk')
55
var Git = require('git-tools')
66

7+
var endsWith = require('ends-with')
78
var objectAssign = require('object-assign')
89

910
var validate = require('./lib/validate')
@@ -12,18 +13,21 @@ var defaults = require('./lib/defaults')
1213

1314
// Need to find the path to the project that is installing
1415
// 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)
1617
function getProjectPath () {
1718
// 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
1920
var p = process.env.PATH.split(':').filter(
2021
function (p) {
21-
return p.endsWith(path.join('commitplease', 'node_modules', '.bin'))
22+
return endsWith(p, path.join('commitplease', 'node_modules', '.bin'))
2223
}
2324
)
2425

2526
if (p.length !== 1) {
2627
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)
2731
}
2832

2933
// Removing suffix node_modules/commitplease/node_modules/.bin will
@@ -37,8 +41,6 @@ function getProjectPath () {
3741
function getOptions () {
3842
var projectPath = getProjectPath()
3943

40-
console.log(projectPath)
41-
4244
var pkg = path.join(projectPath, 'package.json')
4345
var npm = path.join(projectPath, '.npmrc')
4446

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"dependencies": {
3838
"chalk": "^1.1.1",
39+
"ends-with": "^1.0.1",
3940
"git-tools": "^0.2.1",
4041
"ini": "^1.3.4",
4142
"object-assign": "^4.1.0",

0 commit comments

Comments
 (0)