test: fix harness audit env fallback

This commit is contained in:
Affaan Mustafa
2026-04-14 20:03:57 -07:00
parent b2c4b7f51c
commit c54b44edf3

View File

@@ -20,13 +20,20 @@ function cleanup(dirPath) {
function run(args = [], options = {}) { function run(args = [], options = {}) {
const userProfile = options.userProfile || options.homeDir || process.env.USERPROFILE; const userProfile = options.userProfile || options.homeDir || process.env.USERPROFILE;
const env = {
...process.env,
USERPROFILE: userProfile,
};
if (Object.prototype.hasOwnProperty.call(options, 'homeDir')) {
env.HOME = options.homeDir;
} else {
env.HOME = process.env.HOME;
}
const stdout = execFileSync('node', [SCRIPT, ...args], { const stdout = execFileSync('node', [SCRIPT, ...args], {
cwd: options.cwd || path.join(__dirname, '..', '..'), cwd: options.cwd || path.join(__dirname, '..', '..'),
env: { env,
...process.env,
HOME: options.homeDir || process.env.HOME,
USERPROFILE: userProfile,
},
encoding: 'utf8', encoding: 'utf8',
stdio: ['pipe', 'pipe', 'pipe'], stdio: ['pipe', 'pipe', 'pipe'],
timeout: 10000, timeout: 10000,