node
node copied to clipboard
test: add `escapePOSIXShell` util
In https://github.com/nodejs/node/pull/55028, I've tried to come up with an execNode
util, but I couldn't find an implementation that would work for all tests, so I ended up having similar-but-different implementations scattered among several tests. After a bit of soul searching, I realized we could take advantage of string templating and have a util that would escape paths or more when we want to pass them to shell.
Of course, that only works for POSIX shells, where the way we use variables in standardized, however since "
is not a valid char in Windows-paths, and paths are (almost?) always the only arbitrary value we pass to shells in tests, it should do just fine.