Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use class variable to identify InterruptWorkspaceRestoreError error #2689

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
true
);
if (sketchFolderPath) {
this.openFilePromise.reject(new InterruptWorkspaceRestoreError());
this.openFilePromise.reject({
name: 'InterruptWorkspaceRestoreError',
});
await this.openSketch(sketchFolderPath);
}
}
Expand Down Expand Up @@ -329,7 +331,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
// 2. A short timeout resolves the promise automatically, falling back to the usual app launch
await this.openFilePromise.promise;
} catch (err) {
if (err instanceof InterruptWorkspaceRestoreError) {
if (err && (err as any).name === 'InterruptWorkspaceRestoreError') {
// Application has received the `open-file` event and will skip the default application launch
return;
}
Expand Down Expand Up @@ -803,15 +805,6 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
}
}

class InterruptWorkspaceRestoreError extends Error {
constructor() {
super(
"Received 'open-file' event. Interrupting the default launch workflow."
);
Object.setPrototypeOf(this, InterruptWorkspaceRestoreError.prototype);
}
}

// This is a workaround for a limitation with the Theia CLI and `electron-builder`.
// It is possible to run the `electron-builder` with `-c.extraMetadata.foo.bar=36` option.
// On the fly, a `package.json` file will be generated for the final bundled application with the additional `{ "foo": { "bar": 36 } }` metadata.
Expand Down
Loading