From 2b4abb1b13455d035f75e453cdc31a4a489e611d Mon Sep 17 00:00:00 2001 From: bruce-one Date: Mon, 13 Nov 2023 01:00:56 +1100 Subject: [PATCH] Add support for node v20. (#1063) --- src/fs/patch.ts | 4 +++- src/patches/third-party-main.ts | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/fs/patch.ts b/src/fs/patch.ts index c6ce190..2ffa4c2 100644 --- a/src/fs/patch.ts +++ b/src/fs/patch.ts @@ -82,7 +82,9 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) { if (returningArray == null) returningArray = Array.isArray(original.call(this, '')) const res = internalModuleReadFile.call(this, original, ...args) return returningArray && !Array.isArray(res) - ? [res, /"(main|name|type|exports|imports)"/.test(res)] + ? res === '' + ? [] + : [res, /"(main|name|type|exports|imports)"/.test(res)] : res } patches.internalModuleStat = function (this: any, original: any, ...args: any[]) { diff --git a/src/patches/third-party-main.ts b/src/patches/third-party-main.ts index 5cc52fc..3f763a9 100644 --- a/src/patches/third-party-main.ts +++ b/src/patches/third-party-main.ts @@ -55,13 +55,22 @@ export default async function main(compiler: NexeCompiler, next: () => Promise