1
1
import * as path from 'path' ;
2
+ import * as temp from 'temp' ;
2
3
import * as yaml from 'js-yaml' ;
3
4
import * as grpc from '@grpc/grpc-js' ;
4
5
import * as deepmerge from 'deepmerge' ;
@@ -21,6 +22,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
21
22
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables' ;
22
23
23
24
const debounce = require ( 'lodash.debounce' ) ;
25
+ const track = temp . track ( ) ;
24
26
25
27
@injectable ( )
26
28
export class ConfigServiceImpl implements BackendApplicationContribution , ConfigService {
@@ -113,7 +115,17 @@ export class ConfigServiceImpl implements BackendApplicationContribution, Config
113
115
114
116
protected async getFallbackCliConfig ( ) : Promise < DefaultCliConfig > {
115
117
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' } ) ;
117
129
const model = yaml . safeLoad ( rawYaml . trim ( ) ) ;
118
130
return model as DefaultCliConfig ;
119
131
}
0 commit comments