Skip to content

Commit 379a48c

Browse files
committed
Remove a bunch of path API calls.
1 parent 9730b79 commit 379a48c

18 files changed

+138
-162
lines changed

apps/rush-lib/src/api/test/ChangeFile.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
5-
64
import { ChangeFile } from '../ChangeFile';
75
import { RushConfiguration } from '../RushConfiguration';
86
import { ChangeType } from '../ChangeManagement';
97

108
describe(ChangeFile.name, () => {
119
it('can add a change', () => {
12-
const rushFilename: string = path.resolve(__dirname, 'repo', 'rush-npm.json');
10+
const rushFilename: string = `${__dirname}/repo/rush-npm.json`;
1311
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename);
1412

1513
const changeFile: ChangeFile = new ChangeFile(

apps/rush-lib/src/api/test/CommonVersionsConfiguration.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
5-
64
import { CommonVersionsConfiguration } from '../CommonVersionsConfiguration';
75

86
describe(CommonVersionsConfiguration.name, () => {
97
it('can load the file', () => {
10-
const filename: string = path.resolve(__dirname, 'jsonFiles', 'common-versions.json');
8+
const filename: string = `${__dirname}/jsonFiles/common-versions.json`;
119
const configuration: CommonVersionsConfiguration = CommonVersionsConfiguration.loadFromFile(filename);
1210

1311
expect(configuration.preferredVersions.get('@scope/library-1')).toEqual('~3.2.1');

apps/rush-lib/src/api/test/EnvironmentConfiguration.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe(EnvironmentConfiguration.name, () => {
9999
});
100100

101101
it('returns expected path from environment variable with normalization', () => {
102-
const expectedValue: string = path.resolve(path.join(process.cwd(), 'temp'));
102+
const expectedValue: string = path.resolve(process.cwd(), 'temp');
103103
const envVar: string = './temp';
104104
process.env[ENV_VAR] = envVar;
105105

apps/rush-lib/src/api/test/EventHooks.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
54
import { RushConfiguration } from '../RushConfiguration';
65
import { Event, EventHooks } from '../EventHooks';
76

87
describe(EventHooks.name, () => {
98
it('loads a post build hook from rush.json', () => {
10-
const rushFilename: string = path.resolve(__dirname, 'repo', 'rush-npm.json');
9+
const rushFilename: string = `${__dirname}/repo/rush-npm.json`;
1110
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename);
1211
expect(rushConfiguration.eventHooks.get(Event.postRushBuild)).toEqual(['do something']);
1312
});

apps/rush-lib/src/api/test/LastInstallFlag.test.ts

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
54
import { FileSystem } from '@rushstack/node-core-library';
65

76
import { LastInstallFlag } from '../LastInstallFlag';
87

9-
const TEMP_DIR: string = path.join(__dirname, 'temp');
8+
const TEMP_DIR_PATH: string = `${__dirname}/temp`;
109

1110
describe(LastInstallFlag.name, () => {
1211
beforeEach(() => {
13-
FileSystem.ensureEmptyFolder(TEMP_DIR);
12+
FileSystem.ensureEmptyFolder(TEMP_DIR_PATH);
1413
});
1514

1615
afterEach(() => {
17-
FileSystem.ensureEmptyFolder(TEMP_DIR);
16+
FileSystem.ensureEmptyFolder(TEMP_DIR_PATH);
1817
});
1918

2019
it('can create and remove a flag in an empty directory', () => {
2120
// preparation
22-
const flag: LastInstallFlag = new LastInstallFlag(TEMP_DIR);
21+
const flag: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH);
2322
FileSystem.deleteFile(flag.path);
2423

2524
// test state, should be invalid since the file doesn't exist
@@ -38,8 +37,8 @@ describe(LastInstallFlag.name, () => {
3837

3938
it('can detect if the last flag was in a different state', () => {
4039
// preparation
41-
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR, { node: '5.0.0' });
42-
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR, { node: '8.9.4' });
40+
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, { node: '5.0.0' });
41+
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, { node: '8.9.4' });
4342
FileSystem.deleteFile(flag1.path);
4443

4544
// test state, should be invalid since the file doesn't exist
@@ -63,7 +62,7 @@ describe(LastInstallFlag.name, () => {
6362

6463
it('can detect if the last flag was in a corrupted state', () => {
6564
// preparation, write non-json into flag file
66-
const flag: LastInstallFlag = new LastInstallFlag(TEMP_DIR);
65+
const flag: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH);
6766
FileSystem.writeFile(flag.path, 'sdfjkaklfjksldajgfkld');
6867

6968
// test state, should be invalid since the file is not JSON
@@ -72,13 +71,13 @@ describe(LastInstallFlag.name, () => {
7271
});
7372

7473
it("throws an error if new storePath doesn't match the old one", () => {
75-
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR, {
74+
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, {
7675
packageManager: 'pnpm',
77-
storePath: path.join(TEMP_DIR, 'pnpm-store')
76+
storePath: `${TEMP_DIR_PATH}/pnpm-store`
7877
});
79-
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR, {
78+
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, {
8079
packageManager: 'pnpm',
81-
storePath: path.join(TEMP_DIR, 'temp-store')
80+
storePath: `${TEMP_DIR_PATH}/temp-store`
8281
});
8382

8483
flag1.create();
@@ -88,11 +87,11 @@ describe(LastInstallFlag.name, () => {
8887
});
8988

9089
it("doesn't throw an error if conditions for error aren't met", () => {
91-
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR, {
90+
const flag1: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, {
9291
packageManager: 'pnpm',
93-
storePath: path.join(TEMP_DIR, 'pnpm-store')
92+
storePath: `${TEMP_DIR_PATH}/pnpm-store`
9493
});
95-
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR, {
94+
const flag2: LastInstallFlag = new LastInstallFlag(TEMP_DIR_PATH, {
9695
packageManager: 'npm'
9796
});
9897

apps/rush-lib/src/api/test/VersionMismatchFinder.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
5-
64
import { RushConfigurationProject } from '../RushConfigurationProject';
75
import { VersionMismatchFinder } from '../../logic/versionMismatch/VersionMismatchFinder';
86
import { PackageJsonEditor } from '../PackageJsonEditor';
@@ -432,7 +430,7 @@ describe(VersionMismatchFinder.name, () => {
432430
cyclicDependencyProjects: new Set<string>()
433431
} as any as RushConfigurationProject);
434432
const projectB: VersionMismatchFinderEntity = new VersionMismatchFinderCommonVersions(
435-
CommonVersionsConfiguration.loadFromFile(path.resolve(__dirname, 'jsonFiles', 'common-versions.json'))
433+
CommonVersionsConfiguration.loadFromFile(`${__dirname}/jsonFiles/common-versions.json`)
436434
);
437435

438436
const mismatchFinder: VersionMismatchFinder = new VersionMismatchFinder([projectA, projectB]);

apps/rush-lib/src/api/test/VersionPolicy.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'path';
54
import { IPackageJson } from '@rushstack/node-core-library';
65

76
import { VersionPolicyConfiguration } from '../VersionPolicyConfiguration';
87
import { VersionPolicy, LockStepVersionPolicy, IndividualVersionPolicy, BumpType } from '../VersionPolicy';
98

109
describe(VersionPolicy.name, () => {
1110
describe(LockStepVersionPolicy.name, () => {
12-
const filename: string = path.resolve(__dirname, 'jsonFiles', 'rushWithLockVersion.json');
11+
const filename: string = `${__dirname}/jsonFiles/rushWithLockVersion.json`;
1312
const versionPolicyConfig: VersionPolicyConfiguration = new VersionPolicyConfiguration(filename);
1413
let versionPolicy1: VersionPolicy;
1514
let versionPolicy2: VersionPolicy;
@@ -117,7 +116,7 @@ describe(VersionPolicy.name, () => {
117116
});
118117

119118
describe(IndividualVersionPolicy.name, () => {
120-
const fileName: string = path.resolve(__dirname, 'jsonFiles', 'rushWithIndividualVersion.json');
119+
const fileName: string = `${__dirname}/jsonFiles/rushWithIndividualVersion.json`;
121120
const versionPolicyConfig: VersionPolicyConfiguration = new VersionPolicyConfiguration(fileName);
122121
const versionPolicy: VersionPolicy = versionPolicyConfig.getVersionPolicy('testPolicy2');
123122

apps/rush-lib/src/cli/actions/test/AddAction.test.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import '../../test/mockRushCommandLineParser';
55

6-
import * as path from 'path';
7-
86
import { PackageJsonUpdater } from '../../../logic/PackageJsonUpdater';
97
import { RushCommandLineParser } from '../../RushCommandLineParser';
108
import { AddAction } from '../AddAction';
@@ -32,8 +30,8 @@ describe(AddAction.name, () => {
3230

3331
describe(`'add' action`, () => {
3432
it(`adds a dependency to just one repo in the workspace`, async () => {
35-
const startPath: string = path.resolve(__dirname, 'addRepo');
36-
const aPath: string = path.resolve(__dirname, 'addRepo', 'a');
33+
const startPath: string = `${__dirname}/addRepo`;
34+
const aPath: string = `${__dirname}/addRepo/a`;
3735

3836
// Create a Rush CLI instance. This instance is heavy-weight and relies on setting process.exit
3937
// to exit and clear the Rush file lock. So running multiple `it` or `describe` test blocks over the same test
@@ -57,8 +55,8 @@ describe(AddAction.name, () => {
5755

5856
describe(`'add' action with --all`, () => {
5957
it(`adds a dependency to all repos in the workspace`, async () => {
60-
const startPath: string = path.resolve(__dirname, 'addRepo');
61-
const aPath: string = path.resolve(__dirname, 'addRepo', 'a');
58+
const startPath: string = `${__dirname}/addRepo`;
59+
const aPath: string = `${__dirname}/addRepo/a`;
6260

6361
// Create a Rush CLI instance. This instance is heavy-weight and relies on setting process.exit
6462
// to exit and clear the Rush file lock. So running multiple `it` or `describe` test blocks over the same test

apps/rush-lib/src/cli/test/Cli.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Utilities } from '../../utilities/Utilities';
88
describe('CLI', () => {
99
it('should not fail when there is no rush.json', () => {
1010
const workingDir: string = '/';
11-
const startPath: string = path.resolve(path.join(__dirname, '../../../lib/start.js'));
11+
const startPath: string = path.resolve(__dirname, '../../../lib/start.js');
1212

1313
expect(() => {
1414
Utilities.executeCommand({
@@ -22,13 +22,13 @@ describe('CLI', () => {
2222

2323
it('rushx should pass args to scripts', () => {
2424
// Invoke "rushx"
25-
const startPath: string = path.resolve(path.join(__dirname, '../../../lib/startx.js'));
25+
const startPath: string = path.resolve(__dirname, '../../../lib/startx.js');
2626

2727
// Run "rushx show-args 1 2 -x" in the "repo/rushx-project" folder
2828
const output: string = Utilities.executeCommandAndCaptureOutput(
2929
'node',
3030
[startPath, 'show-args', '1', '2', '-x'],
31-
path.join(__dirname, 'repo', 'rushx-project')
31+
`${__dirname}/repo/rushx-project`
3232
);
3333
const lastLine: string =
3434
output
@@ -40,12 +40,12 @@ describe('CLI', () => {
4040

4141
it('rushx should fail in un-rush project', () => {
4242
// Invoke "rushx"
43-
const startPath: string = path.resolve(path.join(__dirname, '../../../lib/startx.js'));
43+
const startPath: string = path.resolve(__dirname, '../../../lib/startx.js');
4444

4545
const output = Utilities.executeCommandAndCaptureOutput(
4646
'node',
4747
[startPath, 'show-args', '1', '2', '-x'],
48-
path.join(__dirname, 'repo', 'rushx-not-in-rush-project')
48+
`${__dirname}/repo/rushx-not-in-rush-project`
4949
);
5050

5151
console.log(output);

apps/rush-lib/src/cli/test/CommandLineHelp.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import { AnsiEscape } from '@rushstack/node-core-library';
55
import * as colorsPackage from 'colors';
6-
import * as path from 'path';
76

87
import { RushCommandLineParser } from '../RushCommandLineParser';
98

@@ -20,7 +19,7 @@ describe('CommandLineHelp', () => {
2019
});
2120

2221
oldCwd = process.cwd();
23-
const localCwd: string = path.join(__dirname, 'repo');
22+
const localCwd: string = `${__dirname}/repo`;
2423

2524
process.chdir(localCwd);
2625

0 commit comments

Comments
 (0)