use home-or-tmp module instead of user-home
The main point about using this instead of just falling back in code is that it depends on an `os.tmpdir()` polyfill [0], which means the tmpdir handling is the same no matter node/iojs version. This is useful as the core `os.tmpdir()` function has changed a lot between node versions. [0]: https://github.com/sindresorhus/os-tmpdir --- `os.tmpdir()` diff between Node 0.10.38 and iojs 2.0.2 ```diff +const trailingSlashRe = isWindows ? /[^:]\\$/ + : /.\/$/; + exports.tmpdir = function() { - return process.env.TMPDIR || - process.env.TMP || - process.env.TEMP || - (process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp'); + var path; + if (isWindows) { + path = process.env.TEMP || + process.env.TMP || + (process.env.SystemRoot || process.env.windir) + '\\temp'; + } else { + path = process.env.TMPDIR || + process.env.TMP || + process.env.TEMP || + '/tmp'; + } + if (trailingSlashRe.test(path)) + path = path.slice(0, -1); + return path; }; ```
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
import userHome from "user-home";
|
||||
import homeOrTmp from "home-or-tmp";
|
||||
|
||||
const FILENAME = process.env.BABEL_CACHE_PATH || path.join(userHome || os.tmpdir(), ".babel.json");
|
||||
const FILENAME = process.env.BABEL_CACHE_PATH || path.join(homeOrTmp, ".babel.json");
|
||||
var data = {};
|
||||
|
||||
export function save() {
|
||||
|
||||
Reference in New Issue
Block a user