electron/patches/node/feat_add_original-fs_module.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

27 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 11 Apr 2019 17:16:13 +0900
Subject: feat: add original-fs module
diff --git a/tools/js2c.py b/tools/js2c.py
index 68152c499ce610d759b5abd659340957efb864d6..3e6ad7d5e12888e26a2b4eaa2eff7e2421b630f7 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -283,6 +283,16 @@ def JS2C(source_files, target):
for filename in source_files['.js']:
AddModule(filename, consts, macros, definitions, initializers)
+ # Electron: Expose fs module without asar support.
+ if name == 'fs.js':
+ # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
+ # dependency. So to expose the unmodified Node 'fs' functionality here,
+ # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
+ # copies to depend on each other instead of on our asarified 'fs' code.
+ # See https://github.com/electron/electron/pull/16028 for more.
+ AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
+ elif name == 'internal/fs/streams.js':
+ AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
config_def, config_size = handle_config_gypi(source_files['config.gypi'])
definitions.append(config_def)