|
1 | 1 | import * as path from 'path';
|
2 | 2 | import { GitUtilities, type GitignoreFilterFn } from '../GitUtilities';
|
| 3 | +import { PackageJsonLookup } from '@rushstack/node-core-library'; |
3 | 4 |
|
4 | 5 | describe('GitUtilities', () => {
|
5 | 6 | describe('checkIgnoreAsync', () => {
|
6 |
| - const testFoldersBasePath: string = path.join(__dirname, 'checkIgnoreTests'); |
| 7 | + const projectRoot: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!; |
| 8 | + |
| 9 | + const testFoldersBasePath: string = `${projectRoot}/src/utilities/test/checkIgnoreTests`; |
7 | 10 |
|
8 | 11 | it('returns all files are ignored', async () => {
|
9 | 12 | const testFolderPath: string = path.join(testFoldersBasePath, 'allIgnored');
|
@@ -37,13 +40,12 @@ describe('GitUtilities', () => {
|
37 | 40 |
|
38 | 41 | it('returns ignored files specified in the repo gitignore', async () => {
|
39 | 42 | // <repoRoot>/apps/heft
|
40 |
| - const testFolderPath: string = path.resolve(__dirname, '..', '..', '..'); |
41 |
| - const git = new GitUtilities(testFolderPath); |
| 43 | + const git = new GitUtilities(projectRoot); |
42 | 44 | const isUnignoredAsync: GitignoreFilterFn = (await git.tryCreateGitignoreFilterAsync())!;
|
43 |
| - expect(await isUnignoredAsync(path.join(testFolderPath, 'lib', 'a.txt'))).toEqual(false); |
44 |
| - expect(await isUnignoredAsync(path.join(testFolderPath, 'temp', 'a.txt'))).toEqual(false); |
45 |
| - expect(await isUnignoredAsync(path.join(testFolderPath, 'dist', 'a.txt'))).toEqual(false); |
46 |
| - expect(await isUnignoredAsync(path.join(testFolderPath, 'src', 'a.txt'))).toEqual(true); |
| 45 | + expect(await isUnignoredAsync(path.join(projectRoot, 'lib', 'a.txt'))).toEqual(false); |
| 46 | + expect(await isUnignoredAsync(path.join(projectRoot, 'temp', 'a.txt'))).toEqual(false); |
| 47 | + expect(await isUnignoredAsync(path.join(projectRoot, 'dist', 'a.txt'))).toEqual(false); |
| 48 | + expect(await isUnignoredAsync(path.join(projectRoot, 'src', 'a.txt'))).toEqual(true); |
47 | 49 |
|
48 | 50 | const ignoredFolderPath: string = path.join(testFoldersBasePath, 'allIgnored');
|
49 | 51 | expect(await isUnignoredAsync(path.join(ignoredFolderPath, 'a.txt'))).toEqual(false);
|
|
0 commit comments