-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18d1d83
commit c23ed70
Showing
6 changed files
with
67 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Set up patched Node | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Set up patched node | ||
shell: bash | ||
run: | | ||
set -exo pipefail | ||
cd $GITHUB_ACTION_PATH | ||
npm init --yes | ||
npm install -D @zkochan/cmd-shim foreground-child | ||
node setup.cjs | ||
- name: Verify patched node | ||
shell: bash | ||
run: node -e 'if (process.getBuiltinModule) { console.log(process.getBuiltinModule) } else { throw new Error("process.getBuiltinModule is not available") }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const path = require("path"); | ||
const { foregroundChild } = require("foreground-child"); | ||
|
||
const argv = process.argv.slice(2); | ||
|
||
const patch = path.resolve(__dirname, "patch.cjs"); | ||
process.env.NODE_OPTIONS = `--no-warnings=ExperimentalWarning --experimental-require-module --require ${patch}`; | ||
|
||
foregroundChild(process.execPath, argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @type {(name: string) => any} */ | ||
process.getBuiltinModule = name => require("module").isBuiltin(name) ? require(name) : undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
if (!process.version.startsWith("v22.")) { | ||
throw new Error("This script is only intended to be used with Node.js v22"); | ||
} | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const cmdShim = require("@zkochan/cmd-shim"); | ||
|
||
const bin = path.resolve(__dirname, "bin"); | ||
fs.mkdirSync(bin, { recursive: true }); | ||
|
||
const src = path.resolve(__dirname, "node.cjs"); | ||
const to = path.resolve(bin, "node"); | ||
|
||
async function main() { | ||
await cmdShim(src, to, { nodeExecPath: process.execPath }); | ||
|
||
if (process.env.GITHUB_PATH) { | ||
fs.appendFileSync(process.env.GITHUB_PATH, bin + "\n"); | ||
} | ||
|
||
for (const f of fs.readdirSync(bin)) { | ||
const contents = fs.readFileSync(path.join(bin, f), "utf8"); | ||
console.log(f); | ||
console.log(contents); | ||
console.log("-".repeat(80)); | ||
} | ||
} | ||
|
||
main().catch(e => { | ||
console.error(e); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
const _module = require("module"); | ||
|
||
/** @type {(name: string) => any} */ | ||
function getBuiltinModule(name) { | ||
if (!_module.isBuiltin(name)) return undefined; | ||
return require(name); | ||
} | ||
|
||
process.getBuiltinModule = getBuiltinModule; | ||
process.getBuiltinModule = name => require("module").isBuiltin(name) ? require(name) : undefined; |