git-off

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

create-pipes.coffee (575B)


      1 
      2 fs = require 'fs'
      3 
      4 timeout = require './timeout'
      5 
      6 
      7 # creates tmp files to pipe process info
      8 #
      9 # @return String path to tmp directory
     10 
     11 module.exports = ->
     12 
     13   t_limit = Date.now() + 1000 # 1 second timeout
     14 
     15   tmp_dir = '/tmp'
     16   for name in ['TMPDIR', 'TMP', 'TEMP']
     17     tmp_dir = dir.replace /\/$/, '' if (dir = process.env[name])?
     18 
     19   until created
     20     try
     21       dir = tmp_dir + '/sync-exec-' + Math.floor Math.random() * 1000000000
     22       fs.mkdir dir
     23       created = true
     24 
     25     timeout t_limit, 'Can not create sync-exec directory'
     26 
     27   # return process-tracking dir name
     28   dir