fix(npx install): Preserve environment so HTTP_PROXY and HTTPS_PROXY go to root user commands.

This commit is contained in:
Bryce J. Fisher 2024-05-28 15:57:37 -06:00
parent 6675652269
commit b587737c14
No known key found for this signature in database
GPG key ID: 03776C01B9C45270

View file

@ -371,6 +371,6 @@ export async function transformCommandsForRoot(commands: string[]): Promise<{ co
return { command: 'sh', args: ['-c', `${commands.join('&& ')}`], elevatedPermissions: false }; return { command: 'sh', args: ['-c', `${commands.join('&& ')}`], elevatedPermissions: false };
const sudoExists = await spawnAsync('which', ['sudo']); const sudoExists = await spawnAsync('which', ['sudo']);
if (sudoExists.code === 0) if (sudoExists.code === 0)
return { command: 'sudo', args: ['--', 'sh', '-c', `${commands.join('&& ')}`], elevatedPermissions: true }; return { command: 'sudo', args: ['--preserve-env', '--', 'sh', '-c', `${commands.join('&& ')}`], elevatedPermissions: true };
return { command: 'su', args: ['root', '-c', `${commands.join('&& ')}`], elevatedPermissions: true }; return { command: 'su', args: ['root', '-c', `${commands.join('&& ')}`], elevatedPermissions: true };
} }