Skip to content

Commit 22f28fa

Browse files
committed
Hard-code scenarios path in development
The scenarios path can still be overridden by setting the config setting.
1 parent cff56b7 commit 22f28fa

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ async function activateWithInstalledDistribution(
11911191
)
11921192
);
11931193

1194-
const mockServer = new MockGitHubApiServer();
1194+
const mockServer = new MockGitHubApiServer(ctx);
11951195
ctx.subscriptions.push(mockServer);
11961196
ctx.subscriptions.push(
11971197
commandRunner(

extensions/ql-vscode/src/mocks/mock-gh-api-server.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { MockGitHubApiConfigListener } from '../config';
2-
1+
import * as fs from 'fs-extra';
2+
import { commands, env, ExtensionContext, ExtensionMode, Uri, window } from 'vscode';
33
import { setupServer, SetupServerApi } from 'msw/node';
4-
import { Recorder } from './recorder';
5-
import { commands, env, Uri, window } from 'vscode';
4+
5+
import { getMockGitHubApiServerScenariosPath, MockGitHubApiConfigListener } from '../config';
66
import { DisposableObject } from '../pure/disposable-object';
7-
import { getMockGitHubApiServerScenariosPath } from '../config';
7+
8+
import { Recorder } from './recorder';
89

910
/**
1011
* Enables mocking of the GitHub API server via HTTP interception, using msw.
@@ -16,7 +17,9 @@ export class MockGitHubApiServer extends DisposableObject {
1617
private readonly server: SetupServerApi;
1718
private readonly recorder: Recorder;
1819

19-
constructor() {
20+
constructor(
21+
private readonly ctx: ExtensionContext,
22+
) {
2023
super();
2124
this.isListening = false;
2225
this.config = new MockGitHubApiConfigListener();
@@ -127,6 +130,13 @@ export class MockGitHubApiServer extends DisposableObject {
127130
return scenariosPath;
128131
}
129132

133+
if (this.ctx.extensionMode === ExtensionMode.Development) {
134+
const developmentScenariosPath = Uri.joinPath(this.ctx.extensionUri, 'src/mocks/scenarios').toString();
135+
if (await fs.pathExists(developmentScenariosPath)) {
136+
return developmentScenariosPath;
137+
}
138+
}
139+
130140
const directories = await window.showOpenDialog({
131141
canSelectFolders: true,
132142
canSelectFiles: false,

0 commit comments

Comments
 (0)