Skip to content

Commit

Permalink
fix: missing fs/promises patches to resolve Not found error (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Nov 13, 2024
1 parent 8913dff commit 93fed60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 6 additions & 2 deletions prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,12 +1722,16 @@ function payloadFileSync(pointer) {
fs.promises.stat = util.promisify(fs.stat);
fs.promises.lstat = util.promisify(fs.lstat);

/*
fs.promises.read = util.promisify(fs.read);
fs.promises.realpath = util.promisify(fs.realpath);
fs.promises.fstat = util.promisify(fs.fstat);
fs.promises.statfs = util.promisify(fs.fstat);
fs.promises.access = util.promisify(fs.access);
*/

// TODO: all promises methods that try to edit files in snapshot should throw
// TODO implement missing methods
// fs.promises.readlink ?
// fs.promises.opendir ?
}

// ///////////////////////////////////////////////////////////////
Expand Down
15 changes: 14 additions & 1 deletion prelude/diagnostic.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function humanSize(bytes) {
return totalSize;
}
function wrap(obj, name) {
const f = fs[name];
const f = obj[name];
obj[name] = (...args) => {
const args1 = Object.values(args);
console.log(
Expand Down Expand Up @@ -111,6 +111,7 @@ function humanSize(bytes) {
wrap(fs, 'open');
wrap(fs, 'readSync');
wrap(fs, 'read');
wrap(fs, 'readFile');
wrap(fs, 'writeSync');
wrap(fs, 'write');
wrap(fs, 'closeSync');
Expand All @@ -131,6 +132,18 @@ function humanSize(bytes) {
wrap(fs, 'exists');
wrap(fs, 'accessSync');
wrap(fs, 'access');

wrap(fs.promises, 'open');
wrap(fs.promises, 'read');
wrap(fs.promises, 'readFile');
wrap(fs.promises, 'write');
wrap(fs.promises, 'readdir');
wrap(fs.promises, 'realpath');
wrap(fs.promises, 'stat');
wrap(fs.promises, 'lstat');
wrap(fs.promises, 'fstat');
wrap(fs.promises, 'access');
wrap(fs.promises, 'copyFile');
}
}
})();

0 comments on commit 93fed60

Please # to comment.