I need to replace all occurrences of a word for another in all txt files. That works if I put like that:
const replace = require('replace-in-file');
const options = {
files: './**/*.txt'
from: /oneWord/g,
to: 'anotherWord,
};
But, I need to use App' user input with process.argv[], and I could not find how to replace the
from: /oneWord/g,
for
from: '/'+ process.argv[3] + '/g'
const replace = require('replace-in-file');
var from = '/'+ process.argv[3] + '/g';
const options = {
files: process.argv[2],
from: process.argv[3],
to: process.argv[4],
Any help?