Skip to content

Commit 32dfe83

Browse files
authored
Update node_patches.js
1 parent ec11fb0 commit 32dfe83

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

internal/node/node_patches.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ function patcher$1(fs = fs__namespace, roots) {
6363
return cb(err);
6464
}
6565
path__namespace.resolve(
66-
// node 20.12 tightened the constraints and requires the input to be a string
67-
String(args[0]),
68-
);
66+
// node 20.12 tightened the constraints and requires the input to be a string
67+
String(args[0]));
6968
if (!stats.isSymbolicLink()) {
7069
return cb(null, stats);
7170
}
@@ -220,9 +219,8 @@ function patcher$1(fs = fs__namespace, roots) {
220219
};
221220
fs.readdir = (...args) => {
222221
const p = path__namespace.resolve(
223-
// node 20.12 tightened the constraints and requires the input to be a string
224-
String(args[0]),
225-
);
222+
// node 20.12 tightened the constraints and requires the input to be a string
223+
String(args[0]));
226224
let cb = args[args.length - 1];
227225
if (typeof cb !== 'function') {
228226
// this will likely throw callback required error.
@@ -235,8 +233,7 @@ function patcher$1(fs = fs__namespace, roots) {
235233
}
236234
// user requested withFileTypes
237235
if (result[0] && result[0].isSymbolicLink) {
238-
Promise
239-
.all(result.map((v) => handleDirent(p, v)))
236+
Promise.all(result.map((v) => handleDirent(p, v)))
240237
.then(() => {
241238
cb(null, result);
242239
})
@@ -254,9 +251,8 @@ function patcher$1(fs = fs__namespace, roots) {
254251
fs.readdirSync = (...args) => {
255252
const res = origReaddirSync(...args);
256253
const p = path__namespace.resolve(
257-
// node 20.12 tightened the constraints and requires the input to be a string
258-
String(args[0]),
259-
);
254+
// node 20.12 tightened the constraints and requires the input to be a string
255+
String(args[0]));
260256
res.forEach((v) => {
261257
handleDirentSync(p, v);
262258
});
@@ -570,21 +566,22 @@ const runfilesPathMatcher = '.runfiles';
570566
function inferRunfilesDirFromPath(maybeRunfilesSource) {
571567
while (maybeRunfilesSource !== '/') {
572568
if (maybeRunfilesSource.endsWith(runfilesPathMatcher)) {
573-
return maybeRunfilesSource + '/';
569+
return (maybeRunfilesSource + '/');
574570
}
575571
maybeRunfilesSource = path__namespace.dirname(maybeRunfilesSource);
576572
}
577573
throw new Error('Path does not contain a runfiles parent directory.');
578574
}
579-
const removeNulls = (value) => value != null;
575+
function removeNulls(value) {
576+
return value != null;
577+
}
580578
function runfilesLocator() {
581579
// Sometimes cwd is under runfiles
582580
const cwd = process.cwd();
583581
// Runfiles environment variables are the preferred reference point, but can fail
584-
const envRunfilesCanidates = [
585-
process.env.RUNFILES_DIR,
586-
process.env.RUNFILES,
587-
].filter(removeNulls).map(runfilesDir => {
582+
const envRunfilesCanidates = [process.env.RUNFILES_DIR, process.env.RUNFILES]
583+
.filter(removeNulls)
584+
.map(runfilesDir => {
588585
const adjustedRunfilesDir = fs__namespace.realpathSync(runfilesDir);
589586
if (runfilesDir !== adjustedRunfilesDir) {
590587
return adjustedRunfilesDir;
@@ -634,15 +631,14 @@ VERBOSE_LOGS, } = process.env;
634631
if (BAZEL_PATCH_ROOTS) {
635632
const roots = BAZEL_PATCH_ROOTS ? BAZEL_PATCH_ROOTS.split(',') : [];
636633
if (VERBOSE_LOGS) {
637-
console
638-
.error(`bazel node patches enabled. roots: ${roots} symlinks in these directories will not escape`);
634+
console.error(`bazel node patches enabled. roots: ${roots} symlinks in these directories will not escape`);
639635
}
640636
const fs = require('fs');
641637
patcher$1(fs, roots);
642638
}
643639
else if (VERBOSE_LOGS) {
644640
console.error(`bazel node patches disabled. set environment BAZEL_PATCH_ROOTS`);
645641
}
646-
return;/*disabled to mitigate #incident-20231108-inspiring-flourish*/// Patch subprocess logic
642+
// Patch subprocess logic
647643
const selfUnderRunfiles = resolveBundleUnderRunfiles(__filename, runfilesLocator());
648644
patcher(selfUnderRunfiles, NP_SUBPROCESS_NODE_DIR);

0 commit comments

Comments
 (0)