diff --git a/__tests__/commands/_helpers.js b/__tests__/commands/_helpers.js index a5c42f9fe9..5e369f6a47 100644 --- a/__tests__/commands/_helpers.js +++ b/__tests__/commands/_helpers.js @@ -101,12 +101,15 @@ export async function run( // remove the lockfile if we create one and it didn't exist before const lockfile = await createLockfile(cwd); + const homeFolderLocation = process.env.YARN_HOME_FOLDER; + process.env.YARN_HOME_FOLDER = path.join(cwd, '.yarn-home'); // create directories await fs.mkdirp(path.join(cwd, '.yarn-global')); await fs.mkdirp(path.join(cwd, '.yarn-link')); await fs.mkdirp(path.join(cwd, '.yarn-cache')); await fs.mkdirp(path.join(cwd, 'node_modules')); + await fs.mkdirp(path.join(cwd, '.yarn-home')); // make sure the cache folder been created in temp folder if (flags.cacheFolder) { @@ -130,5 +133,7 @@ export async function run( } } catch (err) { throw new Error(`${err && err.stack} \nConsole output:\n ${out}`); + } finally { + process.env.YARN_HOME_FOLDER = homeFolderLocation; } } diff --git a/src/registries/npm-registry.js b/src/registries/npm-registry.js index 2c3de01328..176a469918 100644 --- a/src/registries/npm-registry.js +++ b/src/registries/npm-registry.js @@ -97,7 +97,7 @@ export default class NpmRegistry extends Registry { async getPossibleConfigLocations(filename: string): Promise> { const possibles = [ [false, path.join(this.cwd, filename)], - [true, this.config.userconfig || path.join(userHome, filename)], + [true, this.config.userconfig || path.join(process.env.YARN_HOME_FOLDER || userHome, filename)], [false, path.join(getGlobalPrefix(), filename)], ];