33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { writeFile } from 'vs/base/node/pfs' ;
76import product from 'vs/platform/product/common/product' ;
87import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
98import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService' ;
109import { Registry } from 'vs/platform/registry/common/platform' ;
1110import { IConfigurationNode , IConfigurationRegistry , Extensions , IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry' ;
1211import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
1312import { ICommandService } from 'vs/platform/commands/common/commands' ;
13+ import { IFileService } from 'vs/platform/files/common/files' ;
14+ import { VSBuffer } from 'vs/base/common/buffer' ;
15+ import { URI } from 'vs/base/common/uri' ;
1416
1517interface IExportedConfigurationNode {
1618 name : string ;
@@ -33,24 +35,29 @@ export class DefaultConfigurationExportHelper {
3335 constructor (
3436 @IWorkbenchEnvironmentService environmentService : INativeWorkbenchEnvironmentService ,
3537 @IExtensionService private readonly extensionService : IExtensionService ,
36- @ICommandService private readonly commandService : ICommandService ) {
37- if ( environmentService . args [ 'export-default-configuration' ] ) {
38- this . writeConfigModelAndQuit ( environmentService . args [ 'export-default-configuration' ] ) ;
38+ @ICommandService private readonly commandService : ICommandService ,
39+ @IFileService private readonly fileService : IFileService
40+ ) {
41+ const exportDefaultConfigurationPath = environmentService . args [ 'export-default-configuration' ] ;
42+ if ( exportDefaultConfigurationPath ) {
43+ this . writeConfigModelAndQuit ( URI . file ( exportDefaultConfigurationPath ) ) ;
3944 }
4045 }
4146
42- private writeConfigModelAndQuit ( targetPath : string ) : Promise < void > {
43- return Promise . resolve ( this . extensionService . whenInstalledExtensionsRegistered ( ) )
44- . then ( ( ) => this . writeConfigModel ( targetPath ) )
45- . finally ( ( ) => this . commandService . executeCommand ( 'workbench.action.quit' ) )
46- . then ( ( ) => { } ) ;
47+ private async writeConfigModelAndQuit ( target : URI ) : Promise < void > {
48+ try {
49+ await this . extensionService . whenInstalledExtensionsRegistered ( ) ;
50+ await this . writeConfigModel ( target ) ;
51+ } finally {
52+ this . commandService . executeCommand ( 'workbench.action.quit' ) ;
53+ }
4754 }
4855
49- private writeConfigModel ( targetPath : string ) : Promise < void > {
56+ private async writeConfigModel ( target : URI ) : Promise < void > {
5057 const config = this . getConfigModel ( ) ;
5158
5259 const resultString = JSON . stringify ( config , undefined , ' ' ) ;
53- return writeFile ( targetPath , resultString ) ;
60+ await this . fileService . writeFile ( target , VSBuffer . fromString ( resultString ) ) ;
5461 }
5562
5663 private getConfigModel ( ) : IConfigurationExport {
0 commit comments