dotfiles/.vscode/extensions/vscodevim.vim-0.1.10/node_modules/sync-exec/coffee/lib/create-pipes.coffee

29 lines
575 B
CoffeeScript
Raw Normal View History

2016-09-11 09:29:13 +01:00
fs = require 'fs'
timeout = require './timeout'
# creates tmp files to pipe process info
#
# @return String path to tmp directory
module.exports = ->
t_limit = Date.now() + 1000 # 1 second timeout
tmp_dir = '/tmp'
for name in ['TMPDIR', 'TMP', 'TEMP']
tmp_dir = dir.replace /\/$/, '' if (dir = process.env[name])?
until created
try
dir = tmp_dir + '/sync-exec-' + Math.floor Math.random() * 1000000000
fs.mkdir dir
created = true
timeout t_limit, 'Can not create sync-exec directory'
# return process-tracking dir name
dir