Skip to content

Commit 53d5d83

Browse files
committed
Fix launch configs for 1.39.0 and earlier versions
1 parent 20a970e commit 53d5d83

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/app/index.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const tar = require('tar');
2121
const fs = require('fs-extra');
2222

2323
const glspExamplesRepositoryTag = "generator-latest";
24+
const backend = "backend";
25+
const frontend = "frontend";
2426

2527
enum ExtensionType {
2628
HelloWorld = 'hello-world',
@@ -63,6 +65,7 @@ module.exports = class TheiaExtension extends Base {
6365
scripts: string
6466
rootscripts: string
6567
containsTests: boolean
68+
electronMainLocation: string
6669
};
6770

6871
constructor(args: string | string[], options: any) {
@@ -238,7 +241,8 @@ module.exports = class TheiaExtension extends Base {
238241
githubURL,
239242
theiaVersion: options["theia-version"],
240243
lernaVersion: options["lerna-version"],
241-
backend: options["extensionType"] === ExtensionType.Backend
244+
backend: options["extensionType"] === ExtensionType.Backend,
245+
electronMainLocation: this.getElectronMainLocation(options["theia-version"])
242246
}
243247
this.params.dependencies = '';
244248
this.params.browserDevDependencies = '';
@@ -529,6 +533,24 @@ module.exports = class TheiaExtension extends Base {
529533
private _capitalize(name: string): string {
530534
return name.substring(0, 1).toUpperCase() + name.substring(1)
531535
}
536+
537+
private getElectronMainLocation(theiaVersion: string): string {
538+
try {
539+
const semVer = theiaVersion.split('.');
540+
if (semVer.length < 3) {
541+
return backend;
542+
}
543+
const major = Number(semVer[0]);
544+
const minor = Number(semVer[1]);
545+
if ((major === 0) || (major === 1 && minor < 39)) {
546+
return frontend;
547+
}
548+
return backend;
549+
} catch (e) {
550+
return backend;
551+
}
552+
}
532553
}
533554

534-
module.exports.ExtensionType = ExtensionType;
555+
module.exports.ExtensionType = ExtensionType;
556+

templates/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"windows": {
3636
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
3737
},
38-
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
38+
"program": "${workspaceRoot}/electron-app/src-gen/<%= params.electronMainLocation %>/electron-main.js",
3939
"protocol": "inspector",
4040
"args": [
4141
"--loglevel=debug",
@@ -47,7 +47,7 @@
4747
},
4848
"sourceMaps": true,
4949
"outFiles": [
50-
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
50+
"${workspaceRoot}/electron-app/src-gen/<%= params.electronMainLocation %>/electron-main.js",
5151
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
5252
"${workspaceRoot}/*/lib/**/*.js",
5353
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"

0 commit comments

Comments
 (0)