From 0f0869b292f1d7b68ba6e170d628de68a10c009f Mon Sep 17 00:00:00 2001 From: bruce-one Date: Fri, 25 Sep 2020 01:13:22 +1000 Subject: [PATCH] fix: internal module read json changes 12.18.3 (#803) --- src/fs/patch.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fs/patch.ts b/src/fs/patch.ts index ee4b75d..1441e93 100644 --- a/src/fs/patch.ts +++ b/src/fs/patch.ts @@ -317,7 +317,14 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) { log('read (miss) ' + filepath) return original.call(this, ...args) } - patches.internalModuleReadJSON = patches.internalModuleReadFile + let returningArray: boolean + patches.internalModuleReadJSON = function (this: any, original: any, ...args: any[]) { + if (returningArray == null) returningArray = Array.isArray(original.call(this, '')) + const res = patches.internalModuleReadFile.call(this, original, ...args) + return returningArray && !Array.isArray(res) + ? [res, /"(main|name|type|exports|imports)"/.test(res)] + : res + } patches.internalModuleStat = function (this: any, original: any, ...args: any[]) { setupManifest() const filepath = getKey(args[0])