Summary
exec / execFile (and the sync forms) ignore the encoding option. Node defaults to "utf8" (so the callback stdout/stderr are strings), but encoding: "buffer" or encoding: null makes them Buffers.
Today (perry 0.5.1029) js_child_process_exec / js_child_process_exec_file always box stdout/stderr as strings (box_string), so { encoding: "buffer" } still yields strings.
What to do
- Read
encoding from the options object. For "buffer"/null, pass stdout/stderr as Buffers to the callback (and return a Buffer from the no-callback / sync forms); otherwise decode with the named encoding (utf8 default).
- Applies to
exec, execFile, execSync, execFileSync, and ties into the spawnSync Buffer-vs-string default.
Parent: #1780. perry 0.5.1029.
Summary
exec/execFile(and the sync forms) ignore theencodingoption. Node defaults to"utf8"(so the callbackstdout/stderrare strings), butencoding: "buffer"orencoding: nullmakes them Buffers.Today (perry 0.5.1029)
js_child_process_exec/js_child_process_exec_filealways box stdout/stderr as strings (box_string), so{ encoding: "buffer" }still yields strings.What to do
encodingfrom the options object. For"buffer"/null, passstdout/stderrasBuffers to the callback (and return a Buffer from the no-callback / sync forms); otherwise decode with the named encoding (utf8 default).exec,execFile,execSync,execFileSync, and ties into thespawnSyncBuffer-vs-string default.Parent: #1780. perry 0.5.1029.