Skip to content

v0.5.0

Choose a tag to compare

@sursaone sursaone released this 12 Oct 05:31

⚠️ Breaking: env replaces the child's environment

env is now the child's whole environment, as in node-pty, instead of being merged over the parent's. Variables you leave out, such as tokens, no longer reach the child (#47).

If you pass a partial map and rely on inheriting the rest, spread process.env:

spawn("bash", [], { name: "xterm-256color", env: { ...process.env, FOO: "bar" } });

If you already pass { ...process.env, ... } or no env, nothing changes for you.

Changed

  • env replaces the environment (#48)
    • Without env, the child gets the current process.env, so changes made at runtime reach it
    • When the map has no PATH, a bare program name such as sh is still found with the parent's PATH, which does not reach the child
    • On Windows, a map with no entries keeps the parent's environment, as in node-pty
  • The child's environment is built as node-pty builds it on Unix (#49)
    • TERM is set from the name option, which was ignored before, then from TERM in the environment, then "xterm"
    • PWD is set from cwd
    • When the child inherits process.env, the parent's tmux and screen variables (TMUX, STY, ...) and its COLUMNS and LINES are dropped
  • IPtyForkOptions.name is optional, and env: process.env now type-checks (#49)

Thanks to @zgeoff for the report and the contribution!