Map a file into another file in Node.js
npm install map-file
fromis the reading filename- supports relative or absolute
tois the writing filename- supports relative or absolute
- makes nonexistent directories via
fs.mkdir
mapis the function you use to map the content- default returns the original text
callbackis a function to call after mapping- default throws errors and logs success
constmapFile=require("map-file")mapFile({from: "original.css",to: "copy.css",})mapFile({from: "example.css",to: "example.css",map: text=>text.trim(),})mapFile({from: "full.md",to: "summary.md",map: text=>text.slice(0,200),})mapFile({from: "source.txt",to: "target.txt",map: text=>text,},err=>{if(err)throwerr// ...})