mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
Use package.json to detect if workspace is vscode workspace (#286714)
(see https://github.com/microsoft/vscode/issues/285255)
This commit is contained in:
committed by
GitHub
parent
b1bf400da2
commit
e67d7c991b
@@ -31,17 +31,24 @@ export const guessWorkspaceFolder = async () => {
|
||||
}
|
||||
|
||||
for (const folder of vscode.workspace.workspaceFolders) {
|
||||
try {
|
||||
await vscode.workspace.fs.stat(vscode.Uri.joinPath(folder.uri, 'src/vs/loader.js'));
|
||||
if (await isVsCodeWorkspaceFolder(folder)) {
|
||||
return folder;
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export async function isVsCodeWorkspaceFolder(folder: vscode.WorkspaceFolder): Promise<boolean> {
|
||||
try {
|
||||
const buffer = await vscode.workspace.fs.readFile(vscode.Uri.joinPath(folder.uri, 'package.json'));
|
||||
const pkg = JSON.parse(textDecoder.decode(buffer));
|
||||
return pkg.name === 'code-oss-dev';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const getContentFromFilesystem: ContentGetter = async uri => {
|
||||
try {
|
||||
const rawContent = await vscode.workspace.fs.readFile(uri);
|
||||
@@ -58,7 +65,7 @@ export class TestFile {
|
||||
constructor(
|
||||
public readonly uri: vscode.Uri,
|
||||
public readonly workspaceFolder: vscode.WorkspaceFolder
|
||||
) {}
|
||||
) { }
|
||||
|
||||
public getId() {
|
||||
return this.uri.toString().toLowerCase();
|
||||
@@ -169,8 +176,8 @@ export abstract class TestConstruct {
|
||||
}
|
||||
}
|
||||
|
||||
export class TestSuite extends TestConstruct {}
|
||||
export class TestSuite extends TestConstruct { }
|
||||
|
||||
export class TestCase extends TestConstruct {}
|
||||
export class TestCase extends TestConstruct { }
|
||||
|
||||
export type VSCodeTest = TestFile | TestSuite | TestCase;
|
||||
|
||||
Reference in New Issue
Block a user