Add support for node v20. (#1063)

This commit is contained in:
bruce-one
2023-11-13 01:00:56 +11:00
committed by GitHub
parent ca657b5b06
commit 2b4abb1b13
2 changed files with 19 additions and 8 deletions
+3 -1
View File
@@ -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[]) {
+16 -7
View File
@@ -55,13 +55,22 @@ export default async function main(compiler: NexeCompiler, next: () => Promise<v
})
const fileLines = file.contents.toString().split('\n')
fileLines.splice(
location.start.line,
0,
'{{ file("lib/fs/bootstrap.js") }}' +
'\n' +
(semverGt(version, '11.99') ? 'expandArgv1 = false;\n' : '')
)
if (semverGt(version, '19.99')) {
await compiler.replaceInFileAsync(
'lib/internal/modules/cjs/loader.js',
"'use strict';",
"'use strict';\n" + '{{ file("lib/fs/bootstrap.js") }}' + '\n'
)
fileLines.splice(location.start.line, 0, 'expandArgv1 = false;')
} else {
fileLines.splice(
location.start.line,
0,
'{{ file("lib/fs/bootstrap.js") }}' +
'\n' +
(semverGt(version, '11.99') ? 'expandArgv1 = false;\n' : '')
)
}
file.contents = fileLines.join('\n')
if (semverGt(version, '11.99')) {