Skip to content

Commit 913d4da

Browse files
committed
new path rules
1 parent 86fd3b7 commit 913d4da

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ esvu is your one-stop shop for all implementations of ECMAScript.
88
$ npm i -g esvu
99
```
1010

11-
Add `~/.esvu/bin` to your `PATH`.
11+
esvu will attempt to respect `XDG_DATA_HOME`, and will fall back to the
12+
home directory. You will need to add esvu's bin to your `PATH`, for
13+
example `$XDG_DATA_HOME/.esvu/bin` or `/home/snek/.esvu/bin`.
14+
15+
You may override the path entirely by setting the `ESVU_PATH` environment
16+
variable.
1217

1318
## Usage
1419

src/common.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ const extractZip = require('extract-zip');
77
const tar = require('tar');
88
const rimraf = require('rimraf');
99

10-
const ESVU_PATH = path.join(os.homedir(), '.esvu');
10+
const ESVU_PATH = (() => {
11+
const NEW_ESVU_PATH = process.env.ESVU_PATH || path.join(process.env.XDG_DATA_HOME || os.homedir(), '.esvu');
12+
const OLD_ESVU_PATH = path.join(os.homedir(), '.esvu');
13+
14+
try {
15+
fs.statSync(path.join(OLD_ESVU_PATH, 'status.json'));
16+
return OLD_ESVU_PATH;
17+
} catch {
18+
return NEW_ESVU_PATH;
19+
}
20+
})();
21+
1122
const STATUS_PATH = path.join(ESVU_PATH, 'status.json');
1223

1324
async function fileExists(file) {

0 commit comments

Comments
 (0)