Skip to content

Commit

Permalink
use json (#75)
Browse files Browse the repository at this point in the history
* use json

* rename
  • Loading branch information
sandy081 authored Apr 5, 2023
1 parent ad4033e commit 9aad6bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/test-web",
"version": "0.0.39",
"version": "0.0.40",
"scripts": {
"install-extensions": "yarn --cwd=fs-provider && yarn --cwd=sample",
"compile": "tsc -p ./ && yarn compile-fs-provider",
Expand Down
12 changes: 6 additions & 6 deletions src/server/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ function asJSON(value: unknown): string {
}

class Workbench {
constructor(readonly baseUrl: string, readonly dev: boolean, readonly esm: boolean, private readonly builtInExtensions: IScannedBuiltinExtension[] = [], private readonly productOverrides: string = '') { }
constructor(readonly baseUrl: string, readonly dev: boolean, readonly esm: boolean, private readonly builtInExtensions: IScannedBuiltinExtension[] = [], private readonly productOverrides?: Record<string, any>) { }

async render(workbenchWebConfiguration: IWorkbenchOptions): Promise<string> {
const values: { [key: string]: string } = {
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
WORKBENCH_AUTH_SESSION: '',
WORKBENCH_WEB_BASE_URL: this.baseUrl,
WORKBENCH_BUILTIN_EXTENSIONS: asJSON(this.builtInExtensions),
WORKBENCH_PRODUCT_OVERRIDES: this.productOverrides,
WORKBENCH_PRODUCT_OVERRIDES: this.productOverrides ? asJSON(this.productOverrides) : '',
WORKBENCH_MAIN: this.getMain()
};

Expand Down Expand Up @@ -134,7 +134,7 @@ export default function (config: IConfig): Router.Middleware {
router.use(async (ctx, next) => {
if (config.build.type === 'sources') {
const builtInExtensions = await getScannedBuiltinExtensions(config.build.location);
const productOverrides = await getProductOverridesContent(config.build.location);
const productOverrides = await getProductOverrides(config.build.location);
ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/sources`, true, config.esm, builtInExtensions, productOverrides);
} else if (config.build.type === 'static') {
ctx.state.workbench = new Workbench(`${ctx.protocol}://${ctx.host}/static/build`, false, config.esm);
Expand All @@ -160,10 +160,10 @@ export default function (config: IConfig): Router.Middleware {
return router.routes();
}

async function getProductOverridesContent(vsCodeDevLocation: string): Promise<string> {
async function getProductOverrides(vsCodeDevLocation: string): Promise<Record<string, any> | undefined> {
try {
return (await fs.readFile(path.join(vsCodeDevLocation, 'product.overrides.json'))).toString();
return JSON.parse((await fs.readFile(path.join(vsCodeDevLocation, 'product.overrides.json'))).toString());
} catch (e) {
return '';
return undefined;
}
}

0 comments on commit 9aad6bf

Please sign in to comment.