Skip to content
Myr

shell.js

This file

Path

lib/arguments/shell.js

11 lines · 926 bytes · JavaScript

Last changed by

Update dependenciesSindre Sorhusbefore adoptiond49104a

History of this file

Take it

Fix Node 24-specific deprecation warning (#1199)ehmickybefore adoption1ac5b91

lines 1–11why, one step back
1// When the `shell` option is set, any command argument is concatenated as a single string by Node.js:
2// https://github.com/nodejs/node/blob/e38ce27f3ca0a65f68a31cedd984cddb927d4002/lib/child_process.js#L614-L6243// However, since Node 24, it also prints a deprecation warning.4// To avoid this warning, we perform that same operation before calling `node:child_process`.5// Shells only understand strings, which is why Node.js performs that concatenation.6// However, we rely on users splitting command arguments as an array.7// For example, this allows us to easily detect which arguments are passed.8// So we do want users to pass array of arguments even with `shell: true`, but we also want to avoid any warning.9export const concatenateShell = (file, commandArguments, options) => options.shell && commandArguments.length > 010 ? [[file, ...commandArguments].join(' '), [], options]11 : [file, commandArguments, options];