"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/utils/git.js" (7 Feb 2017, 1240 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // handle some git configuration for windows
    2 
    3 exports.spawn = spawnGit
    4 exports.chainableExec = chainableExec
    5 exports.whichAndExec = whichAndExec
    6 
    7 var exec = require('child_process').execFile
    8 var spawn = require('./spawn')
    9 var npm = require('../npm.js')
   10 var which = require('which')
   11 var git = npm.config.get('git')
   12 var assert = require('assert')
   13 var log = require('npmlog')
   14 var noProgressTillDone = require('./no-progress-while-running.js').tillDone
   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, noProgressTillDone(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 whichAndExec (args, options, cb) {
   37   assert.equal(typeof cb, 'function', 'no callback provided')
   38   // check for git
   39   which(git, function (err) {
   40     if (err) {
   41       err.code = 'ENOGIT'
   42       return cb(err)
   43     }
   44 
   45     execGit(args, options, cb)
   46   })
   47 }