Fixed default workspace and empty ws init

This commit is contained in:
Christian Weichel
2019-05-09 09:00:40 +02:00
parent 507fbd0fd1
commit c59a5a6910
5 changed files with 95 additions and 94 deletions

View File

@@ -1,6 +1,5 @@
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs-extra';
import { injectable } from 'inversify';
import { FileUri } from '@theia/core/lib/node/file-uri';
import { DefaultWorkspaceServer } from '@theia/workspace/lib/node/default-workspace-server';
@@ -8,30 +7,8 @@ import { DefaultWorkspaceServer } from '@theia/workspace/lib/node/default-worksp
@injectable()
export class DefaultWorkspaceServerExt extends DefaultWorkspaceServer {
/**
* Reads the most recently used workspace root from the user's home directory.
*/
// tslint:disable-next-line:no-any
protected async readRecentWorkspacePathsFromUserHome(): Promise<any> {
const paths = await super.readRecentWorkspacePathsFromUserHome();
if (!paths || paths.recentRoots.length === 0) {
const defaultWorkspacePath = path.resolve(os.homedir(), 'Arduino-PoC', 'workspace');
if (!fs.existsSync(defaultWorkspacePath)) {
fs.mkdirpSync(defaultWorkspacePath);
}
return {
recentRoots: [
FileUri.create(defaultWorkspacePath)
]
};
}
return paths;
}
async getMostRecentlyUsedWorkspace(): Promise<string | undefined> {
const result = await super.getMostRecentlyUsedWorkspace();
console.log(result);
return result;
protected async getWorkspaceURIFromCli(): Promise<string | undefined> {
return FileUri.create(path.join(os.homedir(), 'Arduino-PoC', 'Sketches')).toString();
}
}