Skip to content

Commit 497b095

Browse files
committed
Update extension to support latest version of CLI
Signed-off-by: worksofliam <[email protected]>
1 parent 73acee2 commit 497b095

File tree

6 files changed

+39
-22
lines changed

6 files changed

+39
-22
lines changed

vs/client/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vs/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vs/server/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vs/server/src/TargetsManager.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { Targets, allExtensions } from "@ibm/sourceorbit";
44
import { ILEObject } from "@ibm/sourceorbit/dist/src/targets";
55

6-
import glob from "glob";
76
import { URI } from 'vscode-uri';
7+
import { ReadFileSystem } from './readFileSystem';
88

99
import path = require("path");
1010

@@ -44,9 +44,10 @@ export class TargetsManager {
4444
const uri = URI.parse(workspaceUri);
4545
const url = uri.fsPath;
4646

47-
const files = getFiles(url, SupportedGlob);
47+
const rfs = new ReadFileSystem();
48+
const files = await rfs.getFiles(url, SupportedGlob);
4849

49-
const targets = new Targets(url);
50+
const targets = new Targets(url, rfs);
5051

5152
targets.loadObjectsFromPaths(files);
5253

@@ -151,12 +152,4 @@ export class TargetsManager {
151152

152153
return [];
153154
}
154-
}
155-
156-
export function getFiles(cwd: string, globPath: string): string[] {
157-
return glob.sync(globPath, {
158-
cwd,
159-
absolute: true,
160-
nocase: true,
161-
});
162155
}

vs/server/src/readFileSystem.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import ffs from 'fs';
2+
import fs from 'fs/promises';
3+
import { glob } from 'glob';
4+
5+
export class ReadFileSystem {
6+
async getFiles(cwd: string, globPath: string): Promise<string[]> {
7+
return glob.sync(globPath, {
8+
cwd,
9+
absolute: true,
10+
nocase: true,
11+
});
12+
}
13+
14+
readFile(filePath: string): Promise<string> {
15+
return fs.readFile(filePath, { encoding: `utf8` });
16+
}
17+
18+
async exists(filePath: string): Promise<boolean> {
19+
return ffs.existsSync(filePath);
20+
}
21+
}

vs/server/src/setup.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { TargetSuggestions } from '@ibm/sourceorbit/dist/src/targets';
44
import fs from 'fs';
55
import path from 'path';
66
import { URI } from 'vscode-uri';
7+
import { ReadFileSystem } from './readFileSystem';
78
import { connection } from './server';
8-
import { SupportedGlob, TargetsManager, getFiles } from './TargetsManager';
9+
import { SupportedGlob, TargetsManager } from './TargetsManager';
910

1011
export async function initAndRefresh(workspaceUri: string) {
1112
const progress = await connection.window.createWorkDoneProgress();
@@ -84,9 +85,11 @@ export async function fixProject(workspaceUri: string, suggestions: TargetSugges
8485
const progress = await connection.window.createWorkDoneProgress();
8586

8687
progress.begin(`Source Orbit`, undefined, `Fetching files..`);
87-
const files = getFiles(url, SupportedGlob);
88+
89+
const rfs = new ReadFileSystem();
90+
const files = await rfs.getFiles(url, SupportedGlob);
8891

89-
const targets = new Targets(url);
92+
const targets = new Targets(url, rfs);
9093
targets.setSuggestions(suggestions);
9194

9295
progress.report(`Loading files..`);

0 commit comments

Comments
 (0)