Skip to content

Commit 133ffa2

Browse files
fix: bundle native dependencies with stricter permissions
1 parent c8c4928 commit 133ffa2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

electron-app/webpack.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const path = require('node:path');
2+
const fs = require('fs');
23
const webpack = require('webpack');
4+
const TheiaNativeWebpackPlugin = require('@theia/native-webpack-plugin');
35
const frontend = require('./gen-webpack.config');
46
const backend = require('./gen-webpack.node.config');
57
const {
@@ -39,6 +41,27 @@ backend.config.entry['parcel-watcher'] = {
3941
},
4042
};
4143

44+
// Override Theia native dependency bundler to assign stricter file permissions (chmod 755)
45+
// https://github.com/eclipse-theia/theia/blob/9a52544fb4c1ea1d3d0d6bcbe106b97184279030/dev-packages/native-webpack-plugin/src/native-webpack-plugin.ts#L149
46+
class NativeWebpackPlugin extends TheiaNativeWebpackPlugin {
47+
// Override the method that writes/copies files
48+
async copyExecutable(source, target) {
49+
const targetDirectory = path.dirname(target);
50+
await fs.promises.mkdir(targetDirectory, { recursive: true });
51+
await fs.promises.copyFile(source, target);
52+
await fs.promises.chmod(target, 0o755);
53+
}
54+
}
55+
backend.config.plugins.push(new NativeWebpackPlugin({
56+
out: 'native',
57+
trash: true,
58+
ripgrep: true,
59+
pty: true,
60+
nativeBindings: {
61+
drivelist: 'drivelist/build/Release/drivelist.node',
62+
},
63+
}));
64+
4265
// Use a customized backend main that can enable the file logger in bundled mode.
4366
backend.config.entry['main'] = require.resolve('./arduino-ide-backend-main.js');
4467

0 commit comments

Comments
 (0)