2 // handle some git configuration for windows
4 exports.spawn = spawnGit
5 exports.chainableExec = chainableExec
6 exports.whichAndExec = whichAndExec
8 var exec = require("child_process").execFile
9 , spawn = require("./spawn")
10 , npm = require("../npm.js")
11 , which = require("which")
12 , git = npm.config.get("git")
13 , assert = require("assert")
14 , log = require("npmlog")
16 function prefixGitArgs () {
17 return process.platform === "win32" ? ["-c", "core.longpaths=true"] : []
20 function execGit (args, options, cb) {
22 var fullArgs = prefixGitArgs().concat(args || [])
23 return exec(git, fullArgs, options, cb)
26 function spawnGit (args, options) {
28 return spawn(git, prefixGitArgs().concat(args || []), options)
31 function chainableExec () {
32 var args = Array.prototype.slice.call(arguments)
33 return [execGit].concat(args)
36 function whichGit (cb) {
40 function whichAndExec (args, options, cb) {
41 assert.equal(typeof cb, "function", "no callback provided")
43 whichGit(function (err) {
49 execGit(args, options, cb)