2.0.0 • Published 3 years ago
node-cli-replace v2.0.0
node-cli-replace
This tool allows you to replace a given query with whatever you want in a file or files.
Install
yarn global add node-cli-replaceUsage
Navigate to the folder where you want to conduct the replace. Then run the following:
node-cli-replace -q __value__ -v foo -f file.ts -i node_modulesThis command will replace the text __value__ with foo.
input
const file = "__value__";output
const file = "foo";If you omit the -v argument, it will remove the value instead of replace it.
Example:
node-cli-replace -q __value__ -f file.ts -i node_modulesinput
const file = "__value__";output
const file = "";Per line
You can add -l flag to change the behaviour to a per-line basis.
Example:
node-cli-replace -q TEST_VALUE= -v NEW_KEY=foo -f prod.env -i node_modules -linput
TEST_VALUE1=testvalue1
TEST_VALUE=testvalueoutput
TEST_VALUE1=testvalue1
NEW_KEY=fooAnd if you omit the -v argument, it will remove that line instead.
Example:
node-cli-replace -q TEST_VALUE= -f prod.env -i node_modules -linput
TEST_VALUE1=testvalue1
TEST_VALUE=testvalueoutput
TEST_VALUE1=testvalue1Display help
dir-search -hSample use-case
- On CI/CD, when you want to replace an existing value in a file with another value during build.