Skip to content

Commit 8c1e195

Browse files
committed
Remove use of getSearchGlob and add new parameter to loadProjects
Signed-off-by: worksofliam <[email protected]>
1 parent bd30cbd commit 8c1e195

File tree

7 files changed

+11
-19
lines changed

7 files changed

+11
-19
lines changed

cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async function main() {
177177
let files: string[];
178178

179179
if (!scanGlob) {
180-
scanGlob = targets.getSearchGlob();
180+
scanGlob = Targets.LanguageProvider.getGlob();
181181
}
182182

183183
try {

cli/src/targets/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ export class Targets {
9595
return ignoredObjects;
9696
}
9797

98-
getSearchGlob(): string {
99-
return Targets.LanguageProvider.getGlob();
100-
}
101-
10298
public getCwd() {
10399
return this.cwd;
104100
}
@@ -139,12 +135,12 @@ export class Targets {
139135
this.resolvedObjects[localPath] = ileObject;
140136
}
141137

142-
public async loadProject(withRef?: string) {
143-
if (withRef) {
144-
await this.handleRefsFile(path.join(this.cwd, withRef));
138+
public async loadProject(options: { withRef?: string, additionalExtensions?: string[] } = {}) {
139+
if (options.withRef) {
140+
await this.handleRefsFile(path.join(this.cwd, options.withRef));
145141
}
146142

147-
const initialFiles = await this.fs.getFiles(this.cwd, this.getSearchGlob());
143+
const initialFiles = await this.fs.getFiles(this.cwd, Targets.LanguageProvider.getGlob(options.additionalExtensions));
148144
await this.loadObjectsFromPaths(initialFiles);
149145
await Promise.allSettled(initialFiles.map(f => this.parseFile(f)));
150146
}

cli/src/targets/languages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class TargetsLanguageProvider {
3333
return this.languageTargets.map(lang => lang.extensions).flat();
3434
}
3535

36-
public getGlob() {
37-
const allExtensions = this.getExtensions();
36+
public getGlob(additionalExtensions: string[] = []): string {
37+
const allExtensions = this.getExtensions().concat(additionalExtensions);
3838
return `**/*.{${allExtensions.join(`,`)},${allExtensions.map(e => e.toUpperCase()).join(`,`)}}`;
3939
}
4040

cli/test/ddsDepsWithRefFile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe(`dds_refs tests with reference file`, () => {
1616
targets.setSuggestions({renames: true, includes: true})
1717

1818
beforeAll(async () => {
19-
await targets.loadProject(`.objrefs`);
19+
await targets.loadProject({withRef: `.objrefs`});
2020

2121
expect(targets.getTargets().length).toBeGreaterThan(0);
2222
targets.resolveBinder();

cli/test/overrideObjRef.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { assert, beforeAll, describe, expect, test } from 'vitest';
1+
import { describe, expect, test } from 'vitest';
22

33
import { Targets } from '../src/targets'
44
import path from 'path';
5-
import { MakeProject } from '../src/builders/make';
6-
import { getFiles } from '../src/utils';
75
import { setupFixture } from './fixtures/projects';
86
import { referencesFileName } from '../src/extensions';
9-
import { writeFileSync } from 'fs';
10-
import { BobProject } from '../src/builders/bob';
117
import { ReadFileSystem } from '../src/readFileSystem';
128

139
const cwd = setupFixture(`override_objref`);

vs/server/src/TargetsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class TargetsManager {
4646

4747
const targets = new Targets(url, rfs);
4848

49-
const files = await rfs.getFiles(url, targets.getSearchGlob());
49+
const files = await rfs.getFiles(url, Targets.LanguageProvider.getGlob());
5050

5151
await targets.loadObjectsFromPaths(files);
5252

vs/server/src/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function fixProject(workspaceUri: string, suggestions: TargetSugges
9393

9494
const targets = new Targets(url, rfs);
9595

96-
const files = await rfs.getFiles(url, targets.getSearchGlob());
96+
const files = await rfs.getFiles(url, Targets.LanguageProvider.getGlob());
9797

9898
targets.setSuggestions(suggestions);
9999

0 commit comments

Comments
 (0)