Ensure directories.user exists.

Closes #1445

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-09-16 11:12:58 +02:00 committed by Akos Kitta
parent b3ab5cbd2a
commit 6983c5bf7f

View File

@ -56,7 +56,10 @@ export class ConfigServiceImpl
this.loadCliConfig().then(async (cliConfig) => {
this.cliConfig = cliConfig;
if (this.cliConfig) {
const config = await this.mapCliConfigToAppConfig(this.cliConfig);
const [config] = await Promise.all([
this.mapCliConfigToAppConfig(this.cliConfig),
this.ensureUserDirExists(this.cliConfig),
]);
if (config) {
this.config = config;
this.ready.resolve();
@ -263,4 +266,11 @@ export class ConfigServiceImpl
grpc.credentials.createInsecure()
) as SettingsServiceClient;
}
// #1445
private async ensureUserDirExists(
cliConfig: DefaultCliConfig
): Promise<void> {
await fs.mkdir(cliConfig.directories.user, { recursive: true });
}
}