Use os-homedir for older node.js versions

This commit is contained in:
Ian Scott 2016-01-28 14:51:16 -08:00
parent e90c1fd239
commit 582bd1a1b2
2 changed files with 6 additions and 3 deletions

View file

@ -49,17 +49,17 @@ function parseXauth( buf )
return auth;
}
var os = require('os');
var homedir = require('os-homedir');
var path = require('path');
function readXauthority(cb) {
var filename = process.env.XAUTHORITY || path.join(os.homedir(), '.Xauthority');
var filename = process.env.XAUTHORITY || path.join(homedir(), '.Xauthority');
fs.readFile(filename, function(err, data) {
if (!err)
return cb(null, data);
if(err.code == 'ENOENT') {
// Xming/windows uses %HOME%/Xauthority ( .Xauthority with no dot ) - try with this name
filename = process.env.XAUTHORITY || path.join(os.homedir(), 'Xauthority');
filename = process.env.XAUTHORITY || path.join(homedir(), 'Xauthority');
return fs.readFile(filename, cb);
} else {
cb(err);

View file

@ -49,5 +49,8 @@
"scripts": {
"test": "node test-runner.js",
"prepublish": "npm prune"
},
"dependencies": {
"os-homedir": "^1.0.1"
}
}