Skip to content

Commit

Permalink
[vscode] don't require non existing plugin main
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
  • Loading branch information
svenefftinge committed May 25, 2020
1 parent ef77343 commit 8bb713f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface PreferenceData {
}

export interface Plugin {
pluginPath: string;
pluginPath: string | undefined;
pluginFolder: string;
model: PluginModel;
rawModel: PluginPackage;
Expand Down
12 changes: 7 additions & 5 deletions packages/plugin-ext/src/hosted/browser/worker/worker-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ const webviewExt = new WebviewsExtImpl(rpc, workspaceExt);
const pluginManager = new PluginManagerExtImpl({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
loadPlugin(plugin: Plugin): any {
if (isElectron()) {
ctx.importScripts(plugin.pluginPath);
} else {
ctx.importScripts('/hostedPlugin/' + getPluginId(plugin.model) + '/' + plugin.pluginPath);
if (plugin.pluginPath) {
if (isElectron()) {
ctx.importScripts(plugin.pluginPath);
} else {
ctx.importScripts('/hostedPlugin/' + getPluginId(plugin.model) + '/' + plugin.pluginPath);
}
}

if (plugin.lifecycle.frontendModuleName) {
Expand Down Expand Up @@ -107,7 +109,7 @@ const pluginManager = new PluginManagerExtImpl({
pluginsModulesNames.set(plugin.lifecycle.frontendModuleName!, plugin);
} else {
foreign.push({
pluginPath: pluginModel.entryPoint.backend!,
pluginPath: pluginModel.entryPoint.backend,
pluginFolder: pluginModel.packagePath,
model: pluginModel,
lifecycle: pluginLifecycle,
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-ext/src/hosted/node/plugin-host-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export class PluginHostRPC {
const { extensionTestsPath } = process.env;
const self = this;
const pluginManager = new PluginManagerExtImpl({
loadPlugin(plugin: Plugin): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
loadPlugin(plugin: Plugin): any {
console.log('PLUGIN_HOST(' + process.pid + '): PluginManagerExtImpl/loadPlugin(' + plugin.pluginPath + ')');
try {
// cleaning the cache for all files of that plug-in.
Expand Down Expand Up @@ -137,7 +138,9 @@ export class PluginHostRPC {
}

});
return require(plugin.pluginPath);
if (plugin.pluginPath) {
return require(plugin.pluginPath);
}
} catch (e) {
console.error(e);
}
Expand Down

0 comments on commit 8bb713f

Please sign in to comment.