Skip to content

Commit e33af0d

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Use init instead of dump for config fallback.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 24dfffa commit e33af0d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: arduino-ide-extension/src/node/config-service-impl.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path';
2+
import * as temp from 'temp';
23
import * as yaml from 'js-yaml';
34
import * as grpc from '@grpc/grpc-js';
45
import * as deepmerge from 'deepmerge';
@@ -21,6 +22,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
2122
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
2223

2324
const debounce = require('lodash.debounce');
25+
const track = temp.track();
2426

2527
@injectable()
2628
export 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

Comments
 (0)