]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/utils/git.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / utils / git.js
1
2 // handle some git configuration for windows
3
4 exports.spawn = spawnGit
5 exports.chainableExec = chainableExec
6 exports.whichAndExec = whichAndExec
7
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")
15
16 function prefixGitArgs () {
17   return process.platform === "win32" ? ["-c", "core.longpaths=true"] : []
18 }
19
20 function execGit (args, options, cb) {
21   log.info('git', args)
22   var fullArgs = prefixGitArgs().concat(args || [])
23   return exec(git, fullArgs, options, cb)
24 }
25
26 function spawnGit (args, options) {
27   log.info("git", args)
28   return spawn(git, prefixGitArgs().concat(args || []), options)
29 }
30
31 function chainableExec () {
32   var args = Array.prototype.slice.call(arguments)
33   return [execGit].concat(args)
34 }
35
36 function whichGit (cb) {
37   return which(git, cb)
38 }
39
40 function whichAndExec (args, options, cb) {
41   assert.equal(typeof cb, "function", "no callback provided")
42   // check for git
43   whichGit(function (err) {
44     if (err) {
45       err.code = "ENOGIT"
46       return cb(err)
47     }
48
49     execGit(args, options, cb)
50   })
51 }