3 ms·
> child_process: spawn() and spawnSync() now support a 'shell' option to allow for optional execution of the given command inside a shell. If set to true, cmd.e
by audessuscest 11y ago
> child_process: spawn() and spawnSync() now support a 'shell' option to allow for optional execution of the given command inside a shell. If set to true, cmd.exe will be used on Windows and /bin/sh elsewhere. A path to a custom shell can also be passed to override these defaults. On Windows, this option allows .bat. and .cmd files to be executed with spawn() and spawnSync(). (Colin Ihrig) #4598
Does this mean that it can now open a real shell (like iTerm) and execute a script ? or I misunderstood ?
- jamescun 11y agoSadly not. When calling spawn[Sync]() in prior versions the command would be executed directly as a child of the node process. If you wanted to use any features like piping, automatic environment variable interpolation or backgrounding etc; you had to manually wrap your command with a system shell like bash(sh). This addition when set to true, will do the wrapping for you in a cross-platform manor.
- audessuscest 11y agoThanks for the clarification
- s_kilk 11y agoThis actually works even today: child_process.exec('open -a Terminal.app') I'm pretty sure you can pass a script arg to the application too, but I haven't done it in a while.
- joshmanders 11y ago> Does this mean that it can now open a real shell (like iTerm) iTerm is not a shell. bash, zsh, fish, etc are shells. iTerm is a terminal program that opens a shell.