shelljs/shx

Regex support for forward slashes in sed

pithyless opened this issue · 2 comments

shx v 0.3.0:

I'm trying to build a cross-platform npm-script and I'm seeing an issue with directory path separators (unix / vs windows \). I thought I could use sed as a workaround, but hit the following issue:

❯ echo '{"js\\foo.js": "js\\foo-1234.js"}' | sed 's/\\/\//g'
{"js/foo.js": "js/foo-1234.js"}

❯ echo '{"js\\foo.js": "js\\foo-1234.js"}' | npx shx sed 's/\\/\//g'
.../node_modules/shx/lib/shx.js:105
        newArgs.push(new RegExp(regexString, regexFlags));
                     ^
SyntaxError: Invalid regular expression: /\/\/: \ at end of pattern
    at new RegExp (<anonymous>)

Thanks for reporting. Looks like a bug. I'll take a closer look at fixing this.

@pithyless fix is released in v0.3.1, let me know if you find any related bugs.