diff --git a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts similarity index 96% rename from src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts rename to src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts index 3a823e02962bbe8cce1fdbb5570582aa75295087..1ad6c0c913099924a398911f8e16658e5be2d24e 100644 --- a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution.ts +++ b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution.ts @@ -9,7 +9,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; -import { DefaultConfigurationExportHelper } from 'vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper'; +import { DefaultConfigurationExportHelper } from 'vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper'; export class ExtensionPoints implements IWorkbenchContribution { diff --git a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.ts similarity index 80% rename from src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts rename to src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.ts index 00f9df83c50054b6625c1a4b1a483745612796a8..a18ff6b0cf672d53826372241f47192d30aad736 100644 --- a/src/vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.ts +++ b/src/vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { writeFile } from 'vs/base/node/pfs'; import product from 'vs/platform/product/common/product'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService'; @@ -11,6 +10,9 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IConfigurationNode, IConfigurationRegistry, Extensions, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ICommandService } from 'vs/platform/commands/common/commands'; +import { IFileService } from 'vs/platform/files/common/files'; +import { VSBuffer } from 'vs/base/common/buffer'; +import { URI } from 'vs/base/common/uri'; interface IExportedConfigurationNode { name: string; @@ -33,24 +35,29 @@ export class DefaultConfigurationExportHelper { constructor( @IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService, @IExtensionService private readonly extensionService: IExtensionService, - @ICommandService private readonly commandService: ICommandService) { - if (environmentService.args['export-default-configuration']) { - this.writeConfigModelAndQuit(environmentService.args['export-default-configuration']); + @ICommandService private readonly commandService: ICommandService, + @IFileService private readonly fileService: IFileService + ) { + const exportDefaultConfigurationPath = environmentService.args['export-default-configuration']; + if (exportDefaultConfigurationPath) { + this.writeConfigModelAndQuit(URI.file(exportDefaultConfigurationPath)); } } - private writeConfigModelAndQuit(targetPath: string): Promise { - return Promise.resolve(this.extensionService.whenInstalledExtensionsRegistered()) - .then(() => this.writeConfigModel(targetPath)) - .finally(() => this.commandService.executeCommand('workbench.action.quit')) - .then(() => { }); + private async writeConfigModelAndQuit(target: URI): Promise { + try { + await this.extensionService.whenInstalledExtensionsRegistered(); + await this.writeConfigModel(target); + } finally { + this.commandService.executeCommand('workbench.action.quit'); + } } - private writeConfigModel(targetPath: string): Promise { + private async writeConfigModel(target: URI): Promise { const config = this.getConfigModel(); const resultString = JSON.stringify(config, undefined, ' '); - return writeFile(targetPath, resultString); + await this.fileService.writeFile(target, VSBuffer.fromString(resultString)); } private getConfigModel(): IConfigurationExport { diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index 2c55e021b4fe463b96e87fde85522fd8062aeb34..d88081d0ba90b5b5ac81132b1be25e7da7c58a47 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -117,7 +117,4 @@ import 'vs/workbench/contrib/tasks/electron-browser/taskService'; // User Data Sync import 'vs/workbench/contrib/userDataSync/electron-browser/userDataSync.contribution'; -// Configuration Exporter -import 'vs/workbench/contrib/configExporter/electron-browser/configurationExportHelper.contribution'; - //#endregion diff --git a/src/vs/workbench/workbench.sandbox.main.ts b/src/vs/workbench/workbench.sandbox.main.ts index 83ff30a2e2ec78c2c360bbcc306c758a7b8cdd98..773b20a0a5e56c659681b26da89f3f3b79e6a922 100644 --- a/src/vs/workbench/workbench.sandbox.main.ts +++ b/src/vs/workbench/workbench.sandbox.main.ts @@ -77,4 +77,7 @@ import 'vs/workbench/contrib/issue/electron-sandbox/issue.contribution'; // Remote import 'vs/workbench/contrib/remote/electron-sandbox/remote.contribution'; +// Configuration Exporter +import 'vs/workbench/contrib/configExporter/electron-sandbox/configurationExportHelper.contribution'; + //#endregion