node icon indicating copy to clipboard operation
node copied to clipboard

test: add `escapePOSIXShell` util

Open aduh95 opened this issue 5 months ago • 8 comments

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.

aduh95 avatar Sep 25 '24 21:09 aduh95