Closed mesqueeb closed 4 years ago
This is already possible: https://github.com/adamreisnz/replace-in-file#using-callbacks-for-to
This callback provides for an extra argument above the String replace method, which is the name of the file in which the replacement is being performed.
const options = {
files: 'path/to/file',
from: /SomePattern[A-Za-z-]+/g,
to: (...args) => args.pop(), //The last argument is the filename
};
I'd love to be able to insert the filename when replacing something.
Eg. the example below would