File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -7,7 +7,18 @@ const extractZip = require('extract-zip');
77const tar = require ( 'tar' ) ;
88const 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+
1122const STATUS_PATH = path . join ( ESVU_PATH , 'status.json' ) ;
1223
1324async function fileExists ( file ) {
You can’t perform that action at this time.
0 commit comments