Skip to content

Commit 5f22ddb

Browse files
committed
docs: clarify PYTHONUTF8 is a fallback and document env inheritance in JSDoc
1 parent 58d8ee0 commit 5f22ddb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/common/childProcess.apis.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ export interface ExecResult {
1515
* Executes a command and returns the result as a promise.
1616
* This function abstracts cp.exec to make it easier to mock in tests.
1717
*
18+
* Environment handling: process.env is always inherited, with options.env merged on top.
19+
* PYTHONUTF8='1' is set as a fallback (can be overridden by process.env or options.env).
20+
*
1821
* @param command The command to execute (can include arguments).
1922
* @param options Optional execution options.
2023
* @returns A promise that resolves with { stdout, stderr } strings.
2124
*/
2225
export async function execProcess(command: string, options?: cp.ExecOptions): Promise<ExecResult> {
23-
// Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default
26+
// Sets PYTHONUTF8='1' as fallback, then inherits process.env, then merges options.env overrides
2427
const env = {
2528
PYTHONUTF8: '1',
2629
...process.env,
@@ -38,6 +41,9 @@ export async function execProcess(command: string, options?: cp.ExecOptions): Pr
3841
* Spawns a new process using the specified command and arguments.
3942
* This function abstracts cp.spawn to make it easier to mock in tests.
4043
*
44+
* Environment handling: process.env is always inherited, with options.env merged on top.
45+
* PYTHONUTF8='1' is set as a fallback (can be overridden by process.env or options.env).
46+
*
4147
* When stdio: 'pipe' is used, returns ChildProcessWithoutNullStreams.
4248
* Otherwise returns the standard ChildProcess.
4349
*/
@@ -58,7 +64,7 @@ export function spawnProcess(
5864
args: string[],
5965
options?: cp.SpawnOptions,
6066
): cp.ChildProcess | cp.ChildProcessWithoutNullStreams {
61-
// Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default
67+
// Sets PYTHONUTF8='1' as fallback, then inherits process.env, then merges options.env overrides
6268
const env = {
6369
PYTHONUTF8: '1',
6470
...process.env,

0 commit comments

Comments
 (0)