mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-12 22:06:34 +00:00
Fixed the FS path issue on Windows.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
41c603937c
commit
9ae721292d
@ -457,12 +457,9 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
|||||||
|
|
||||||
let sketches: Sketch[] = [];
|
let sketches: Sketch[] = [];
|
||||||
const config = await this.configService.getConfiguration();
|
const config = await this.configService.getConfiguration();
|
||||||
const result = config.sketchDirPath;
|
const stat = await this.fileSystem.getFileStat(config.sketchDirUri);
|
||||||
if (!!result) {
|
if (!!stat) {
|
||||||
const stat = await this.fileSystem.getFileStat(result);
|
sketches = await this.sketches.getSketches(stat);
|
||||||
if (!!stat) {
|
|
||||||
sketches = await this.sketches.getSketches(stat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sketches;
|
return sketches;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ export class AWorkspaceService extends WorkspaceService {
|
|||||||
let result = await super.getDefaultWorkspacePath();
|
let result = await super.getDefaultWorkspacePath();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
const config = await this.configService.getConfiguration();
|
const config = await this.configService.getConfiguration();
|
||||||
result = config.sketchDirPath;
|
result = config.sketchDirUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stat = await this.fileSystem.getFileStat(result);
|
const stat = await this.fileSystem.getFileStat(result);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export const ConfigServicePath = '/services/config-service';
|
export const ConfigServicePath = '/services/config-service';
|
||||||
export const ConfigService = Symbol('ConfigService');
|
export const ConfigService = Symbol('ConfigService');
|
||||||
|
|
||||||
@ -7,6 +6,6 @@ export interface ConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
sketchDirPath: string;
|
sketchDirUri: string;
|
||||||
dataDirPath: string;
|
dataDirUri: string;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,17 @@ import * as os from 'os';
|
|||||||
import * as which from 'which';
|
import * as which from 'which';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
import { join, delimiter } from 'path';
|
import { join, delimiter } from 'path';
|
||||||
import { injectable } from 'inversify';
|
import { injectable, inject } from 'inversify';
|
||||||
|
import { ILogger } from '@theia/core';
|
||||||
|
import { FileUri } from '@theia/core/lib/node/file-uri';
|
||||||
import { Config } from '../common/protocol/config-service';
|
import { Config } from '../common/protocol/config-service';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ArduinoCli {
|
export class ArduinoCli {
|
||||||
|
|
||||||
|
@inject(ILogger)
|
||||||
|
protected logger: ILogger;
|
||||||
|
|
||||||
async getExecPath(): Promise<string> {
|
async getExecPath(): Promise<string> {
|
||||||
const build = join(__dirname, '..', '..', 'build');
|
const build = join(__dirname, '..', '..', 'build');
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
@ -47,25 +52,33 @@ export class ArduinoCli {
|
|||||||
for (const line of raw.split(/\r?\n/) || []) {
|
for (const line of raw.split(/\r?\n/) || []) {
|
||||||
// TODO: Named capture groups are avail from ES2018.
|
// TODO: Named capture groups are avail from ES2018.
|
||||||
// const pair = line.match(/(?<key>[^:]+):(?<value>[^,]+),?/);
|
// const pair = line.match(/(?<key>[^:]+):(?<value>[^,]+),?/);
|
||||||
const pair = line.split(':').map(entry => entry.trim());
|
const index = line.indexOf(':');
|
||||||
if (pair[0] === 'sketchbook_path') {
|
if (index !== -1) {
|
||||||
config.sketchDirPath = pair[1];
|
const key = line.substr(0, index).trim();
|
||||||
} else if (pair[0] === 'arduino_data') {
|
const value = line.substr(index + 1, line.length).trim();
|
||||||
config.dataDirPath = pair[1];
|
if (!!key && !!value) {
|
||||||
|
if (key === 'sketchbook_path') {
|
||||||
|
config.sketchDirUri = FileUri.create(value).toString();
|
||||||
|
} else if (key === 'arduino_data') {
|
||||||
|
config.dataDirUri = FileUri.create(value).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.dataDirPath) {
|
if (!config.dataDirUri) {
|
||||||
reject(new Error(`Could not parse config. 'arduino_data' was missing from: ${stdout}`));
|
reject(new Error(`Could not parse config. 'arduino_data' was missing from: ${stdout}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.sketchDirPath) {
|
if (!config.sketchDirUri) {
|
||||||
reject(new Error(`Could not parse config. 'sketchbook_path' was missing from: ${stdout}`));
|
reject(new Error(`Could not parse config. 'sketchbook_path' was missing from: ${stdout}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({ sketchDirPath: config.sketchDirPath, dataDirPath: config.dataDirPath });
|
this.logger.info(`Retrieved the default configuration from the CLI: ${JSON.stringify(config)}`);
|
||||||
|
|
||||||
|
resolve({ sketchDirUri: config.sketchDirUri, dataDirUri: config.dataDirUri });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
import { ArduinoCli } from './arduino-cli';
|
import { ArduinoCli } from './arduino-cli';
|
||||||
import { Instance } from './cli-protocol/commands/common_pb';
|
import { Instance } from './cli-protocol/commands/common_pb';
|
||||||
import { CoreClientProvider, Client } from './core-client-provider';
|
import { CoreClientProvider, Client } from './core-client-provider';
|
||||||
|
import { FileUri } from '@theia/core/lib/node';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class CoreClientProviderImpl implements CoreClientProvider {
|
export class CoreClientProviderImpl implements CoreClientProvider {
|
||||||
@ -79,7 +80,9 @@ export class CoreClientProviderImpl implements CoreClientProvider {
|
|||||||
throw new Error(`Could not resolve filesystem path of URI: ${rootUri}.`);
|
throw new Error(`Could not resolve filesystem path of URI: ${rootUri}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { dataDirPath, sketchDirPath } = await this.cli.getDefaultConfig();
|
const { dataDirUri, sketchDirUri } = await this.cli.getDefaultConfig();
|
||||||
|
const dataDirPath = FileUri.fsPath(dataDirUri);
|
||||||
|
const sketchDirPath = FileUri.fsPath(sketchDirUri);
|
||||||
|
|
||||||
if (!fs.existsSync(dataDirPath)) {
|
if (!fs.existsSync(dataDirPath)) {
|
||||||
fs.mkdirSync(dataDirPath);
|
fs.mkdirSync(dataDirPath);
|
||||||
@ -90,7 +93,7 @@ export class CoreClientProviderImpl implements CoreClientProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const downloadDir = path.join(dataDirPath, 'staging');
|
const downloadDir = path.join(dataDirPath, 'staging');
|
||||||
if (fs.existsSync(downloadDir)) {
|
if (!fs.existsSync(downloadDir)) {
|
||||||
fs.mkdirSync(downloadDir);
|
fs.mkdirSync(downloadDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { injectable, inject } from 'inversify';
|
import { injectable, inject } from 'inversify';
|
||||||
import { FileUri } from '@theia/core/lib/node/file-uri';
|
|
||||||
import { DefaultWorkspaceServer } from '@theia/workspace/lib/node/default-workspace-server';
|
import { DefaultWorkspaceServer } from '@theia/workspace/lib/node/default-workspace-server';
|
||||||
import { ConfigService } from '../common/protocol/config-service';
|
import { ConfigService } from '../common/protocol/config-service';
|
||||||
|
|
||||||
@ -10,7 +9,7 @@ export class DefaultWorkspaceServerExt extends DefaultWorkspaceServer {
|
|||||||
|
|
||||||
protected async getWorkspaceURIFromCli(): Promise<string | undefined> {
|
protected async getWorkspaceURIFromCli(): Promise<string | undefined> {
|
||||||
const config = await this.configService.getConfiguration();
|
const config = await this.configService.getConfiguration();
|
||||||
return FileUri.create(config.sketchDirPath).toString();
|
return config.sketchDirUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user