electron/patches/node/feat_initialize_asar_support.patch
Samuel Attard 9a7426dc25 build: use our patch system to apply patches to upstream node (#19270)
This points our node repo at upstream (nodejs/node) and uses the base node tag as the target ref.  We then use our existing patch system and patch files to apply our changes on top of node.  This unifies how we patch upstream repos and makes our node patches easier to reason, view, understand and most importantly reduce.
2019-07-16 10:23:04 -07:00

42 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 08:56:07 -0700
Subject: feat: initialize asar support
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index 7a98e4c96c87d4738829aadf1969ee90eda3876a..bf63de07613b4d19d95607f404139e587319f11d 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -189,6 +189,8 @@ function nativeModuleRequire(id) {
return mod.compile();
}
+NativeModule.require = nativeModuleRequire
+
NativeModule.exists = function(id) {
return NativeModule.map.has(id);
};
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 24d25158f9e8adf5f2265504a21daa5ed96f517a..2351268eae27af7ae759dccb599c071e146ece71 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -51,6 +51,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
initializeCJSLoader();
initializeESMLoader();
loadPreloadModules();
+ setupAsarSupport();
}
function patchProcessObject(expandArgv1) {
@@ -393,6 +394,10 @@ function loadPreloadModules() {
}
}
+function setupAsarSupport() {
+ process._linkedBinding('atom_common_asar').initAsarSupport(require);
+}
+
module.exports = {
patchProcessObject,
setupCoverageHooks,