• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const os = require('os')
2const { resolve } = require('path')
3
4module.exports = (fakePlatform = false) => {
5  const temp = os.tmpdir()
6  const uidOrPid = process.getuid ? process.getuid() : process.pid
7  const home = os.homedir() || resolve(temp, 'npm-' + uidOrPid)
8  const platform = fakePlatform || process.platform
9  const cacheExtra = platform === 'win32' ? 'npm-cache' : '.npm'
10  const cacheRoot = (platform === 'win32' && process.env.LOCALAPPDATA) || home
11  return {
12    cacache: resolve(cacheRoot, cacheExtra, '_cacache'),
13    tufcache: resolve(cacheRoot, cacheExtra, '_tuf'),
14  }
15}
16