mirror of
https://github.com/danbulant/node-x11
synced 2026-06-15 12:41:29 +00:00
Use os-homedir for older node.js versions
This commit is contained in:
parent
e90c1fd239
commit
582bd1a1b2
2 changed files with 6 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -49,5 +49,8 @@
|
|||
"scripts": {
|
||||
"test": "node test-runner.js",
|
||||
"prepublish": "npm prune"
|
||||
},
|
||||
"dependencies": {
|
||||
"os-homedir": "^1.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue