Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cygpath for cygwin-based git executable #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"dependencies": {
"is-ci": "^1.0.9",
"normalize-path": "^1.0.0"
"normalize-path": "^1.0.0",
"which": "^1.2.11"
}
}
14 changes: 13 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs')
var path = require('path')
var exec = require('child_process').exec
var normalize = require('normalize-path')
var which = require('which')

module.exports = {
isHusky: function (filename) {
Expand All @@ -14,7 +15,18 @@ module.exports = {
if (error) {
callback(stderr, null)
} else {
callback(null, stdout.trim() + '/hooks')
var hooksPath = stdout.trim() + '/hooks'
if (process.platform === 'win32' && which.sync('cygpath')) {
exec('cygpath -w ' + hooksPath, function (cygError, cygStdout, cygStdErr) {
if (cygError) {
callback(cygStdEr, null)
} else {
callback(null, cygStdout.trim())
}
})
} else {
callback(null, hooksPath)
}
}
})
},
Expand Down
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ var fs = require('fs')
var path = require('path')
var rmrf = require('rimraf')
var husky = require('../src/')
var normalize = require('normalize-path')

// Some very basic tests...

// should return git hooks path
husky.hooksDir(function (err, dir) {
assert.equal(err, null)
assert.equal(dir, '.git/hooks')
assert.equal(normalize(dir), '.git/hooks')
})

// Reset tmp dir
Expand Down