-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove unsafe remove of install folder (#372)
* fix: remove unsafe remove of install folder * test: update to use folderUtils * perf: skip `existsSync` check
- Loading branch information
Showing
4 changed files
with
27 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,13 @@ import {Filename, ppath, xfs, npath, PortablePath} from '@yarnpkg/fslib'; | |
import process from 'node:process'; | ||
|
||
import config from '../config.json'; | ||
import * as folderUtils from '../sources/folderUtils'; | ||
|
||
import {runCli} from './_runCli'; | ||
|
||
let corepackHome!: PortablePath; | ||
|
||
beforeEach(async () => { | ||
corepackHome = await xfs.mktempPromise(); | ||
|
||
process.env.COREPACK_HOME = npath.fromPortablePath(corepackHome); | ||
process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise()); | ||
process.env.COREPACK_DEFAULT_TO_LATEST = `0`; | ||
}); | ||
|
||
|
@@ -101,7 +99,7 @@ for (const [name, version] of testedPackageManagers) { | |
} | ||
|
||
it(`should update the Known Good Release only when the major matches`, async () => { | ||
await xfs.writeJsonPromise(ppath.join(corepackHome, `lastKnownGood.json`), { | ||
await xfs.writeJsonPromise(ppath.join(npath.toPortablePath(folderUtils.getCorepackHomeFolder()), `lastKnownGood.json`), { | ||
yarn: `1.0.0`, | ||
}); | ||
|
||
|
@@ -645,7 +643,7 @@ it(`should not override the package manager exit code`, async () => { | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
const yarnFolder = ppath.join(corepackHome, `yarn/2.2.2`); | ||
const yarnFolder = ppath.join(npath.toPortablePath(folderUtils.getInstallFolder()), `yarn/2.2.2`); | ||
await xfs.mkdirPromise(yarnFolder, {recursive: true}); | ||
await xfs.writeJsonPromise(ppath.join(yarnFolder, `.corepack`), {}); | ||
|
||
|
@@ -670,7 +668,7 @@ it(`should not preserve the process.exitCode when a package manager throws`, asy | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
const yarnFolder = ppath.join(corepackHome, `yarn/2.2.2`); | ||
const yarnFolder = ppath.join(npath.toPortablePath(folderUtils.getInstallFolder()), `yarn/2.2.2`); | ||
await xfs.mkdirPromise(yarnFolder, {recursive: true}); | ||
await xfs.writeJsonPromise(ppath.join(yarnFolder, `.corepack`), {}); | ||
|
||
|
@@ -693,7 +691,7 @@ it(`should not set the exit code after successfully launching the package manage | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
const yarnFolder = ppath.join(corepackHome, `yarn/2.2.2`); | ||
const yarnFolder = ppath.join(npath.toPortablePath(folderUtils.getInstallFolder()), `yarn/2.2.2`); | ||
await xfs.mkdirPromise(yarnFolder, {recursive: true}); | ||
await xfs.writeJsonPromise(ppath.join(yarnFolder, `.corepack`), {}); | ||
|
||
|
@@ -719,7 +717,7 @@ it(`should support package managers in ESM format`, async () => { | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
const yarnFolder = ppath.join(corepackHome, `yarn/2.2.2`); | ||
const yarnFolder = ppath.join(npath.toPortablePath(folderUtils.getInstallFolder()), `yarn/2.2.2`); | ||
await xfs.mkdirPromise(yarnFolder, {recursive: true}); | ||
await xfs.writeJsonPromise(ppath.join(yarnFolder, `.corepack`), {}); | ||
|
||
|