11import * as path from 'path' ;
2+ import * as temp from 'temp' ;
23import * as yaml from 'js-yaml' ;
34import * as grpc from '@grpc/grpc-js' ;
45import * as deepmerge from 'deepmerge' ;
@@ -21,6 +22,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
2122import { EnvVariablesServer } from '@theia/core/lib/common/env-variables' ;
2223
2324const debounce = require ( 'lodash.debounce' ) ;
25+ const track = temp . track ( ) ;
2426
2527@injectable ( )
2628export class ConfigServiceImpl implements BackendApplicationContribution , ConfigService {
@@ -113,7 +115,17 @@ export class ConfigServiceImpl implements BackendApplicationContribution, Config
113115
114116 protected async getFallbackCliConfig ( ) : Promise < DefaultCliConfig > {
115117 const cliPath = await this . daemon . getExecPath ( ) ;
116- const rawYaml = await spawnCommand ( `"${ cliPath } "` , [ 'config' , 'dump' ] ) ;
118+ const throwawayDirPath = await new Promise < string > ( ( resolve , reject ) => {
119+ track . mkdir ( { } , ( err , dirPath ) => {
120+ if ( err ) {
121+ reject ( err ) ;
122+ return ;
123+ }
124+ resolve ( dirPath ) ;
125+ } ) ;
126+ } ) ;
127+ await spawnCommand ( `"${ cliPath } "` , [ 'config' , 'init' , '--dest-dir' , throwawayDirPath ] ) ;
128+ const rawYaml = await fs . readFile ( path . join ( throwawayDirPath , CLI_CONFIG ) , { encoding : 'utf-8' } ) ;
117129 const model = yaml . safeLoad ( rawYaml . trim ( ) ) ;
118130 return model as DefaultCliConfig ;
119131 }
0 commit comments