Reading ASAR using fs in render process (within html file)


#1

Inside a <code> block in an html file, I’m trying to access (with fs.readFileSync) a file that is stored inside the ASAR. To get to the fs module I’m using…

var fs = require('remote').require('fs');
var contents = fs.readFileSync(...etc...);

This result in…

Error: ENOENT, no such file or directory 'C:\Users\... redacted ... '
    at Error (native)
    at Object.fs.openSync (fs.js:503:18)
    at Object.module.(anonymous function) [as openSync] (ATOM_SHELL_ASAR.js:118:20)
    at Object.fs.readFileSync (fs.js:355:15)
    at Object.fs.readFileSync (ATOM_SHELL_ASAR.js:362:29)
    ... etc ...

Maybe the fs ASAR magic doesn’t work when jumping through the process barrier like this? I have a workaround, but just wondering if I’m doing something wrong.

This is Windows btw, and a very old Electron (actually pre-Electron, Atom Shell): 0.21.2