git-off

git off handles large files in git repos
git clone https://noulin.net/git/git-off.git
Log | Files | Refs | README

sync-exec.js (1562B)


      1 // Generated by CoffeeScript 1.9.3
      2 (function() {
      3   var child_process, create_pipes, proxy, read_pipes, timeout;
      4 
      5   child_process = require('child_process');
      6 
      7   create_pipes = require('./lib/create-pipes');
      8 
      9   proxy = require('./lib/proxy');
     10 
     11   read_pipes = require('./lib/read-pipes');
     12 
     13   timeout = require('./lib/timeout');
     14 
     15   module.exports = function(cmd, max_wait, options) {
     16     var dir, ref;
     17     if (max_wait && typeof max_wait === 'object') {
     18       ref = [max_wait, null], options = ref[0], max_wait = ref[1];
     19     }
     20     if (options == null) {
     21       options = {};
     22     }
     23     if (!options.hasOwnProperty('encoding')) {
     24       options.encoding = 'utf8';
     25     }
     26     if (!(typeof options === 'object' && options)) {
     27       throw new Error('options must be an object');
     28     }
     29     if (max_wait == null) {
     30       max_wait = options.timeout || options.max_wait || 3600000;
     31     }
     32     if (!((max_wait == null) || max_wait >= 1)) {
     33       throw new Error('`options.timeout` must be >=1 millisecond');
     34     }
     35     delete options.max_wait;
     36     if (options.forceEmulation) {
     37       delete options.forceEmulation;
     38     } else if (child_process.execSync) {
     39       return proxy(cmd, max_wait, options);
     40     }
     41     delete options.timeout;
     42     dir = create_pipes();
     43     cmd = '((((' + cmd + ' > ' + dir + '/stdout 2> ' + dir + '/stderr ) ' + '&& echo $? > ' + dir + '/status) || echo $? > ' + dir + '/status) &&' + ' echo 1 > ' + dir + '/done) || echo 1 > ' + dir + '/done';
     44     child_process.exec(cmd, options, function() {});
     45     return read_pipes(dir, max_wait);
     46   };
     47 
     48 }).call(this);