refactor(npm): Use util function for cache dir creation (#10591)

This commit is contained in:
Sergei Zharinov 2021-06-24 17:06:04 +04:00 committed by GitHub
parent 21d2aeb720
commit d2b0f4d98b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,7 @@ import { ExternalHostError } from '../../../types/errors/external-host-error';
import { getChildProcessEnv } from '../../../util/exec/env'; import { getChildProcessEnv } from '../../../util/exec/env';
import { import {
deleteLocalFile, deleteLocalFile,
ensureDir, ensureCacheDir,
getSiblingFileName, getSiblingFileName,
getSubDirectory, getSubDirectory,
outputFile, outputFile,
@ -434,24 +434,16 @@ export async function getAdditionalFiles(
const { additionalNpmrcContent, additionalYarnRcYml } = processHostRules(); const { additionalNpmrcContent, additionalYarnRcYml } = processHostRules();
const env = getChildProcessEnv([ const env = {
'NPM_CONFIG_CACHE', ...getChildProcessEnv(),
'YARN_CACHE_FOLDER', NPM_CONFIG_CACHE: await ensureCacheDir('./others/npm', 'NPM_CONFIG_CACHE'),
'npm_config_store', YARN_CACHE_FOLDER: await ensureCacheDir(
]); './others/yarn',
env.NPM_CONFIG_CACHE = 'YARN_CACHE_FOLDER'
env.NPM_CONFIG_CACHE || ),
upath.join(getAdminConfig().cacheDir, './others/npm'); npm_config_store: await ensureCacheDir('./others/pnpm', 'npm_config_store'),
await ensureDir(env.NPM_CONFIG_CACHE); NODE_ENV: 'dev',
env.YARN_CACHE_FOLDER = };
env.YARN_CACHE_FOLDER ||
upath.join(getAdminConfig().cacheDir, './others/yarn');
await ensureDir(env.YARN_CACHE_FOLDER);
env.npm_config_store =
env.npm_config_store ||
upath.join(getAdminConfig().cacheDir, './others/pnpm');
await ensureDir(env.npm_config_store);
env.NODE_ENV = 'dev';
let token = ''; let token = '';
try { try {