|
1 | | -import {Filename, ppath, xfs, npath, PortablePath} from '@yarnpkg/fslib'; |
2 | | -import os from 'node:os'; |
3 | | -import process from 'node:process'; |
4 | | -import {beforeEach, describe, expect, it} from 'vitest'; |
| 1 | +import {Filename, ppath, xfs, npath, PortablePath} from '@yarnpkg/fslib'; |
| 2 | +import os from 'node:os'; |
| 3 | +import process from 'node:process'; |
| 4 | +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; |
5 | 5 |
|
6 | | -import config from '../config.json'; |
7 | | -import * as folderUtils from '../sources/folderUtils'; |
8 | | -import {SupportedPackageManagerSet} from '../sources/types'; |
| 6 | +import config from '../config.json'; |
| 7 | +import * as folderUtils from '../sources/folderUtils'; |
| 8 | +import {SupportedPackageManagerSet} from '../sources/types'; |
9 | 9 |
|
10 | | -import {runCli} from './_runCli'; |
| 10 | +import {runCli} from './_runCli'; |
11 | 11 |
|
12 | 12 |
|
13 | 13 | beforeEach(async () => { |
| 14 | + const home = await xfs.mktempPromise(); |
| 15 | + |
14 | 16 | // `process.env` is reset after each tests in setupTests.js. |
15 | | - process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise()); |
| 17 | + process.env.COREPACK_HOME = npath.fromPortablePath(home); |
16 | 18 | process.env.COREPACK_DEFAULT_TO_LATEST = `0`; |
| 19 | + |
| 20 | + return async () => { |
| 21 | + await xfs.removePromise(home, {recursive: true}); |
| 22 | + }; |
17 | 23 | }); |
18 | 24 |
|
19 | 25 | it(`should refuse to download a package manager if the hash doesn't match`, async () => { |
@@ -480,6 +486,12 @@ it(`should support disabling the network accesses from the environment`, async ( |
480 | 486 | }); |
481 | 487 |
|
482 | 488 | describe(`read-only and offline environment`, () => { |
| 489 | + afterEach(async () => { |
| 490 | + const home = npath.toPortablePath(process.env.COREPACK_HOME!); |
| 491 | + await xfs.chmodPromise(ppath.join(home, `lastKnownGood.json`), 0o644); |
| 492 | + await xfs.chmodPromise(home, 0o755); |
| 493 | + }); |
| 494 | + |
483 | 495 | it(`should support running in project scope`, async () => { |
484 | 496 | await xfs.mktempPromise(async cwd => { |
485 | 497 | // Reset to default |
|
0 commit comments