create-pipes.js (777B)
1 // Generated by CoffeeScript 1.9.3 2 (function() { 3 var fs, timeout; 4 5 fs = require('fs'); 6 7 timeout = require('./timeout'); 8 9 module.exports = function() { 10 var created, dir, i, len, name, ref, t_limit, tmp_dir; 11 t_limit = Date.now() + 1000; 12 tmp_dir = '/tmp'; 13 ref = ['TMPDIR', 'TMP', 'TEMP']; 14 for (i = 0, len = ref.length; i < len; i++) { 15 name = ref[i]; 16 if ((dir = process.env[name]) != null) { 17 tmp_dir = dir.replace(/\/$/, ''); 18 } 19 } 20 while (!created) { 21 try { 22 dir = tmp_dir + '/sync-exec-' + Math.floor(Math.random() * 1000000000); 23 fs.mkdir(dir); 24 created = true; 25 } catch (_error) {} 26 timeout(t_limit, 'Can not create sync-exec directory'); 27 } 28 return dir; 29 }; 30 31 }).call(this);