mirror of
https://github.com/samsonjs/repl-edit.git
synced 2026-03-25 09:25:49 +00:00
if TMPDIR is not set in the environment try /tmp and fallback to cwd
This commit is contained in:
parent
01c7ab03ff
commit
4304827207
1 changed files with 13 additions and 1 deletions
14
lib/index.js
14
lib/index.js
|
|
@ -10,6 +10,18 @@
|
|||
var fs = require('fs')
|
||||
, repl = require('repl')
|
||||
, _repl
|
||||
, _tmpdir
|
||||
|
||||
// Find a suitable directory to store the REPL session
|
||||
if (process.env['TMPDIR']) _tmpdir = process.env['TMPDIR']
|
||||
else {
|
||||
try {
|
||||
fs.statSync('/tmp')
|
||||
_tmpdir = '/tmp'
|
||||
} catch (e) {
|
||||
_tmpdir = process.cwd()
|
||||
}
|
||||
}
|
||||
|
||||
exports.startRepl = function() {
|
||||
console.log('Commands: edit(), run(), stash(filename), unstash(filename), setEditor(editor)')
|
||||
|
|
@ -24,7 +36,7 @@ exports.extend = function(obj) {
|
|||
var path = require('path')
|
||||
, spawn = require('child_process').spawn
|
||||
, sys = require('sys')
|
||||
, _tmpfile = path.join(process.env['TMPDIR'], 'node-repl-' + process.pid + '.js')
|
||||
, _tmpfile = path.join(_tmpdir, 'node-repl-' + process.pid + '.js')
|
||||
|
||||
obj.edit = function(editor) {
|
||||
editor = editor || process.ENV['EDITOR']
|
||||
|
|
|
|||
Loading…
Reference in a new issue