[Code] Fix Java langserver cannot start when workspace doesn't exist (#46685) (#46709)

This commit is contained in:
Pengcheng Xu 2019-09-27 11:11:48 +08:00 committed by GitHub
parent 0b75d84286
commit 3b9a4ffed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@
*/
import { execFile, spawn } from 'child_process';
import { existsSync } from 'fs';
import { existsSync, mkdirSync } from 'fs';
import getPort from 'get-port';
import * as glob from 'glob';
import { platform as getOsPlatform } from 'os';
@ -177,6 +177,11 @@ export class JavaLauncher extends AbstractLauncher {
);
}
// Check if workspace exists before launching
if (!existsSync(this.options.jdtWorkspacePath)) {
mkdirSync(this.options.jdtWorkspacePath);
}
const p = spawn(javaPath, params, {
cwd: this.options.jdtWorkspacePath,
detached: false,