我需要在所有txt文件中替换所有出现的单词。 如果我这样说,那就有用了:
const replace = require('replace-in-file');
const options = {
files: './**/*.txt'
from: /oneWord/g,
to: 'anotherWord,
};
但是,我需要使用App'用户输入process.argv [],我找不到如何替换
from: /oneWord/g,
代表
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],
任何帮助?
答案 0 :(得分:0)
在选项中,您必须放置变量而不是process.argv [3]。