Skip to content

Commit 8c6051e

Browse files
author
Benjamin Pasero
committed
another attempt at ASAR
1 parent f34d169 commit 8c6051e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/bootstrap-window.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ exports.assign = function assign(destination, source) {
3636
exports.load = function (modulePaths, resultCallback, options) {
3737
// @ts-ignore
3838
const webFrame = require('electron').webFrame;
39+
const path = require('path');
3940

4041
const args = exports.parseURLQueryArgs();
4142
const configuration = JSON.parse(args['config'] || '{}') || {};
@@ -55,7 +56,7 @@ exports.load = function (modulePaths, resultCallback, options) {
5556
exports.assign(process.env, configuration.userEnv);
5657

5758
// Enable ASAR support
58-
bootstrap.enableASARSupport();
59+
bootstrap.enableASARSupport(path.join(configuration.appRoot, 'node_modules'));
5960

6061
// disable pinch zoom & apply zoom level early to avoid glitches
6162
const zoomLevel = configuration.zoomLevel;

src/bootstrap.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ process.on('SIGPIPE', () => {
2121
//#endregion
2222

2323
//#region Add support for using node_modules.asar
24-
exports.enableASARSupport = function () {
24+
/**
25+
* @param {string=} nodeModulesPath
26+
*/
27+
exports.enableASARSupport = function (nodeModulesPath) {
2528
// @ts-ignore
2629
const Module = require('module');
2730
const path = require('path');
28-
const NODE_MODULES_PATH = path.join(__dirname, '../node_modules');
31+
let NODE_MODULES_PATH = nodeModulesPath;
32+
if (!NODE_MODULES_PATH) {
33+
NODE_MODULES_PATH = path.join(__dirname, '../node_modules');
34+
}
35+
2936
const NODE_MODULES_ASAR_PATH = NODE_MODULES_PATH + '.asar';
3037

3138
const originalResolveLookupPaths = Module._resolveLookupPaths;

0 commit comments

Comments
 (0)