|
3 | 3 | * SPDX-License-Identifier: Apache-2.0 |
4 | 4 | */ |
5 | 5 | import assert from 'assert' |
6 | | -import { createTestWorkspaceFolder, readEnvPath, withEnvPath } from '../../testUtil' |
| 6 | +import { createTestWorkspaceFolder, envWithNewPath, readEnv, withEnv } from '../../testUtil' |
7 | 7 |
|
8 | | -describe('withEnvPath', function () { |
| 8 | +describe('withEnv', function () { |
9 | 9 | it('resets path when error in task', async function () { |
10 | | - const originalPath = readEnvPath() |
| 10 | + const originalEnv = readEnv() |
11 | 11 | const tempFolder = await createTestWorkspaceFolder() |
12 | 12 | try { |
13 | | - await withEnvPath(tempFolder.uri.fsPath, async () => { |
| 13 | + await withEnv(envWithNewPath(tempFolder.uri.fsPath), async () => { |
14 | 14 | throw new Error() |
15 | 15 | }) |
16 | 16 | } catch {} |
17 | | - assert.strictEqual(readEnvPath(), originalPath) |
| 17 | + assert.strictEqual(readEnv().PATH, originalEnv.PATH) |
18 | 18 | }) |
19 | 19 |
|
20 | 20 | it('changes $PATH temporarily', async function () { |
21 | | - const originalPath = readEnvPath() |
| 21 | + const originalEnv = readEnv() |
22 | 22 | const tempFolder = await createTestWorkspaceFolder() |
23 | | - await withEnvPath(tempFolder.uri.fsPath, async () => { |
24 | | - assert.strictEqual(readEnvPath(), tempFolder.uri.fsPath) |
| 23 | + await withEnv(envWithNewPath(tempFolder.uri.fsPath), async () => { |
| 24 | + assert.strictEqual(readEnv().PATH, tempFolder.uri.fsPath) |
25 | 25 | }) |
26 | | - assert.strictEqual(readEnvPath(), originalPath) |
| 26 | + assert.strictEqual(readEnv().PATH, originalEnv.PATH) |
27 | 27 | }) |
28 | 28 | }) |
0 commit comments