mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-14 14:56:33 +00:00
Use init
instead of dump
for config fallback.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
24dfffa976
commit
e33af0d78a
@ -1,4 +1,5 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as temp from 'temp';
|
||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
import * as grpc from '@grpc/grpc-js';
|
import * as grpc from '@grpc/grpc-js';
|
||||||
import * as deepmerge from 'deepmerge';
|
import * as deepmerge from 'deepmerge';
|
||||||
@ -21,6 +22,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
|
|||||||
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
||||||
|
|
||||||
const debounce = require('lodash.debounce');
|
const debounce = require('lodash.debounce');
|
||||||
|
const track = temp.track();
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ConfigServiceImpl implements BackendApplicationContribution, ConfigService {
|
export class ConfigServiceImpl implements BackendApplicationContribution, ConfigService {
|
||||||
@ -113,7 +115,17 @@ export class ConfigServiceImpl implements BackendApplicationContribution, Config
|
|||||||
|
|
||||||
protected async getFallbackCliConfig(): Promise<DefaultCliConfig> {
|
protected async getFallbackCliConfig(): Promise<DefaultCliConfig> {
|
||||||
const cliPath = await this.daemon.getExecPath();
|
const cliPath = await this.daemon.getExecPath();
|
||||||
const rawYaml = await spawnCommand(`"${cliPath}"`, ['config', 'dump']);
|
const throwawayDirPath = await new Promise<string>((resolve, reject) => {
|
||||||
|
track.mkdir({}, (err, dirPath) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(dirPath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await spawnCommand(`"${cliPath}"`, ['config', 'init', '--dest-dir', throwawayDirPath]);
|
||||||
|
const rawYaml = await fs.readFile(path.join(throwawayDirPath, CLI_CONFIG), { encoding: 'utf-8' });
|
||||||
const model = yaml.safeLoad(rawYaml.trim());
|
const model = yaml.safeLoad(rawYaml.trim());
|
||||||
return model as DefaultCliConfig;
|
return model as DefaultCliConfig;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user