-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save cached config to standard directories
Instead of placing the configuration file in the home directory it should be placed in the [appropriate directory](https://wiki.archlinux.org/index.php/XDG_Base_Directory_support) per OS. Breaking change: resolves issue #37
- Loading branch information
Showing
3 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const path = require('path'); | ||
const userHome = require('user-home'); | ||
|
||
const env = process.env; | ||
const name = 'js-v8flags'; | ||
|
||
function macos () { | ||
const library = path.join(userHome, 'Library'); | ||
return path.join(library, 'Caches', name); | ||
} | ||
|
||
function windows () { | ||
const appData = env.LOCALAPPDATA || path.join(userHome, 'AppData', 'Local'); | ||
return path.join(appData, name, 'Cache'); | ||
} | ||
|
||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html | ||
function linux () { | ||
const username = path.basename(userHome); | ||
return path.join(env.XDG_CACHE_HOME || path.join(userHome, '.cache'), name); | ||
} | ||
|
||
module.exports = function (platform) { | ||
if (platform === 'darwin') { | ||
return macos(); | ||
} | ||
|
||
if (platform === 'win32') { | ||
return windows(); | ||
} | ||
|
||
return linux(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters