I'm using replace-in-file to find all references to "old/site/ and replace with File_Path.
File_Path is a variable that is declared globaly.
Here's is my config
let FILE_PATH;
const replace = require('replace-in-file');
const options = {
// file to update
files: './output.js',
// replacement to make (string or regex)
from: "old/site/",
to: "FILE_PATH+",
};
// asynchronous replacement with promises:
replace(options)
.then(changedFiles => {
console.log('Modified files:', changedFiles.join(', '));
})
.catch(error => {
console.error('Error occurred:', error);
});
So as you can see 'to' is set to "FILE_PATH+" which gives the result
"FILE_PATH+childurl"
The result I am looking for though is
FILE_PATH+"childurl
How do I pass a ref of the variable and not the var name as a string?
EDIT
I have a script called output.js I have a update_script.js
output.js contains this line of code
e.exports=n.p+"old/site/logo.svg"
update_script.js is running the code above which finds all references to "old/site/" and replaces it with "FILE_PATH+" so the new path looks like
What I want
e.exports=n.p+FILE_PATH+"/logo.svg"
So my question is how do I pass FILE_PATH without passing it as a string. Right now when I pass "FILE_PATH+" the url get update to
What I get
e.exports=n.p+"+FILE_PATH+/logo.svg"
to: "FILE_PATH+"toto: FILE_PATH + "+"?FILE_PATH? Can you give an example of its value and what effect that has on the replacement?