-
Notifications
You must be signed in to change notification settings - Fork 744
Can't make sed perform global replace #719
Description
Node version (or tell us if you're using electron or some other framework):
Node 6.9.2 with VueJS and Quasar
ShellJS version (the most recent version/Github branch you see the bug on):
shelljs@0.7.7
Operating system:
Debian 7.11
Description of the bug:
I'm trying to use shell.sed() inside a node build script to adjust the contents of a CSS file. The file has already been processed by various other optimisers, and so is on a single line. Therefore, I need to use a 'global' replace in the sed call, and I can't figure out how to do that - otherwise it just replaces the first occurance.
Example ShellJS command to reproduce the error:
To 'repoint' font source references which currently read src: url(app/Roboto... and should read src: url(Roboto..., I'm using this (not sure why double-escape is needed on the 'find' param, but it errors out otherwise):
shell.sed('-i', 'src:url\\(app\\/', 'src:url\\(', cssFiles)
The end result is that the very first reference to src: url(app/Roboto... has been replaced, but the others are all still wrong. It's not clear how to tell shell.sed() to add a 'g' to the search term.