mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 14:41:29 +00:00

PR-URL: https://github.com/nodejs/node/pull/42122 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Danielle Adams <adamzdanielle@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
13 lines
515 B
JavaScript
13 lines
515 B
JavaScript
const os = require('os')
|
|
const { resolve } = require('path')
|
|
|
|
module.exports = (fakePlatform = false) => {
|
|
const temp = os.tmpdir()
|
|
const uidOrPid = process.getuid ? process.getuid() : process.pid
|
|
const home = os.homedir() || resolve(temp, 'npm-' + uidOrPid)
|
|
const platform = fakePlatform || process.platform
|
|
const cacheExtra = platform === 'win32' ? 'npm-cache' : '.npm'
|
|
const cacheRoot = (platform === 'win32' && process.env.LOCALAPPDATA) || home
|
|
return resolve(cacheRoot, cacheExtra, '_cacache')
|
|
}
|