git-off

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

proxy.js (881B)


      1 // Generated by CoffeeScript 1.9.3
      2 (function() {
      3   var child_process;
      4 
      5   child_process = require('child_process');
      6 
      7   module.exports = function(cmd, max_wait, options) {
      8     var err, orig_write, status, stderr, stdout, t0;
      9     options.timeout = max_wait;
     10     stdout = stderr = '';
     11     status = 0;
     12     t0 = Date.now();
     13     orig_write = process.stderr.write;
     14     process.stderr.write = function() {};
     15     try {
     16       stdout = child_process.execSync(cmd, options);
     17       process.stderr.write = orig_write;
     18     } catch (_error) {
     19       err = _error;
     20       process.stderr.write = orig_write;
     21       if (err.signal === 'SIGTERM' && t0 <= Date.now() - max_wait) {
     22         throw new Error('Timeout');
     23       }
     24       stdout = err.stdout, stderr = err.stderr, status = err.status;
     25     }
     26     return {
     27       stdout: stdout,
     28       stderr: stderr,
     29       status: status
     30     };
     31   };
     32 
     33 }).call(this);