HEX
Server: Apache
System: Linux pdx1-shared-a1-29 6.18.39-grsec-noble+ #4 SMP Thu Jul 23 07:53:29 UTC 2026 x86_64
User: dh_bj99yp (22285841)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //usr/share/nodejs/node-preload/generate-require.js
'use strict';

const path = require('path');

const needsPathRegExp = /[\\ "]/;

const needsPathEnv = dir => needsPathRegExp.test(dir);

function generateRequire(filename) {
	if (needsPathEnv(filename)) {
		return `--require ${path.basename(filename)}`;
	}

	return `--require ${filename}`;
}

function processNodePath(value) {
	const dir = path.dirname(require.resolve('./preload-path/node-preload.js'));
	const existing = value === '' ? [] : value.split(path.delimiter);
	if (existing.includes(dir)) {
		return value;
	}

	return existing.concat(dir).join(path.delimiter);
}

module.exports = {
	generateRequire,
	processNodePath,
	needsPathEnv
};