From 3ca0d8192205c73e069b04b47d748077283dcfb9 Mon Sep 17 00:00:00 2001 From: Caleb Boyd Date: Sat, 8 Mar 2025 10:01:02 -0600 Subject: [PATCH] fix(node22): handle new arg order (#1120) --- package.json | 2 +- src/fs/patch.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2116ac2..7b4b007 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nexe", "description": "Create a single executable out of your Node.js application", "license": "MIT", - "version": "5.0.0-beta.3", + "version": "5.0.0-beta.4", "contributors": [ "Craig Condon (http://crcn.io)", "Jared Allard ", diff --git a/src/fs/patch.ts b/src/fs/patch.ts index 2ffa4c2..b345c0c 100644 --- a/src/fs/patch.ts +++ b/src/fs/patch.ts @@ -88,14 +88,19 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) { : res } patches.internalModuleStat = function (this: any, original: any, ...args: any[]) { - log(`internalModuleStat ${args[0]}`) + let statPath = args[0] + //in node 22, the path arg moved to arg[1] + if (typeof args[0] !== 'string') statPath = args[1] + let result = 0 try { - const stat = posixSnapshotZipFs.statSync(args[0]) - if (stat.isDirectory()) return 1 - return 0 + const stat = posixSnapshotZipFs.statSync(statPath) + if (stat.isDirectory()) result = 1 + else result = 0 } catch (e) { - return -constants.ENOENT + result = -constants.ENOENT } + log(`internalModuleStat ${result} ${statPath}`) + return result } lazyRestoreFs = () => {