I have file containing following lines that I want to adjust with script.
module.exports = {
parserOptions: {
project: ['./tsconfig.json'],
},
... more stuff here
}
so it looks like this. I dont really care about whitespaces in the result.
module.exports = {
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname
},
... more stuff here
}
What I have now is:
sed -r "s/project:\s*\['.\/tsconfig.json'\],/project:\['.\/tsconfig.json'\],\ntsconfigRootDir\:__dirname/g" filename
but it doesnt get matched. I tried the matching pattern on this site https://sed.js.org/index.html?snippet=y7KG95 and there I get the result I want. I also tried using sed -E
but no luck.
I would say the script setup works OK because changing something simple like s/project/projectA/g
works fine.
Thanks!
Using macOS Monterey 12.5.1