Skip to content

Commit

Permalink
Support fix-path in non-bundled environments
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Feb 4, 2025
1 parent 424c048 commit 575e3e7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
34 changes: 17 additions & 17 deletions dev-packages/application-manager/src/generator/backend-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ export class BackendGenerator extends AbstractGenerator {
require('@theia/core/shared/reflect-metadata');
// Useful for Electron/NW.js apps as GUI apps on macOS doesn't inherit the \`$PATH\` define
// in your dotfiles (.bashrc/.bash_profile/.zshrc/etc).
// https://github.com/electron/electron/issues/550#issuecomment-162037357
// https://github.com/eclipse-theia/theia/pull/3534#issuecomment-439689082
require('@theia/core/electron-shared/fix-path').default();
// Workaround for https://github.com/electron/electron/issues/9225. Chrome has an issue where
// in certain locales (e.g. PL), image metrics are wrongly computed. We explicitly set the
// LC_NUMERIC to prevent this from happening (selects the numeric formatting category of the
Expand All @@ -52,18 +46,24 @@ if (process.env.LC_ALL) {
}
process.env.LC_NUMERIC = 'C';
const { resolve } = require('path');
const theiaAppProjectPath = resolve(__dirname, '..', '..');
process.env.THEIA_APP_PROJECT_PATH = theiaAppProjectPath;
const { default: electronMainApplicationModule } = require('@theia/core/lib/electron-main/electron-main-application-module');
const { ElectronMainApplication, ElectronMainApplicationGlobals } = require('@theia/core/lib/electron-main/electron-main-application');
const { Container } = require('@theia/core/shared/inversify');
const { app } = require('electron');
const config = ${this.prettyStringify(this.pck.props.frontend.config)};
const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
(async () => {
// Useful for Electron/NW.js apps as GUI apps on macOS doesn't inherit the \`$PATH\` define
// in your dotfiles (.bashrc/.bash_profile/.zshrc/etc).
// https://github.com/electron/electron/issues/550#issuecomment-162037357
// https://github.com/eclipse-theia/theia/pull/3534#issuecomment-439689082
(await require('@theia/core/electron-shared/fix-path')).default();
const { resolve } = require('path');
const theiaAppProjectPath = resolve(__dirname, '..', '..');
process.env.THEIA_APP_PROJECT_PATH = theiaAppProjectPath;
const { default: electronMainApplicationModule } = require('@theia/core/lib/electron-main/electron-main-application-module');
const { ElectronMainApplication, ElectronMainApplicationGlobals } = require('@theia/core/lib/electron-main/electron-main-application');
const { Container } = require('@theia/core/shared/inversify');
const { app } = require('electron');
const config = ${this.prettyStringify(this.pck.props.frontend.config)};
const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
if (isSingleInstance && !app.requestSingleInstanceLock()) {
// There is another instance running, exit now. The other instance will request focus.
app.quit();
Expand Down
1 change: 0 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export class SomeClass {
- `native-keymap` (from [`native-keymap@^2.2.1`](https://www.npmjs.com/package/native-keymap))
- `electron` (from [`[email protected]`](https://www.npmjs.com/package/electron/v/30.1.2))
- `electron-store` (from [`electron-store@^8.0.0`](https://www.npmjs.com/package/electron-store))
- `fix-path` (from [`fix-path@^4.0.0`](https://www.npmjs.com/package/fix-path))
- `@theia/core/shared/...`
- `@phosphor/algorithm` (from [`@phosphor/algorithm@1`](https://www.npmjs.com/package/@phosphor/algorithm))
- `@phosphor/commands` (from [`@phosphor/commands@1`](https://www.npmjs.com/package/@phosphor/commands))
Expand Down
1 change: 0 additions & 1 deletion packages/electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The `@theia/electron` extension bundles all Electron-specific dependencies and c
- `native-keymap` (from [`native-keymap@^2.2.1`](https://www.npmjs.com/package/native-keymap))
- `electron` (from [`[email protected]`](https://www.npmjs.com/package/electron/v/30.1.2))
- `electron-store` (from [`electron-store@^8.0.0`](https://www.npmjs.com/package/electron-store))
- `fix-path` (from [`fix-path@^4.0.0`](https://www.npmjs.com/package/fix-path))

## Additional Information

Expand Down
5 changes: 2 additions & 3 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
],
"export =": [
"electron as Electron",
"electron-store as ElectronStore",
"fix-path as fixPath"
"electron-store as ElectronStore"
]
}
},
"publishConfig": {
"access": "public"
},
"theiaExtensions": [ ],
"theiaExtensions": [],
"keywords": [
"theia-extension"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/shared/fix-path/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('fix-path');
module.exports = import('fix-path');

0 comments on commit 575e3e7

Please sign in to comment.