0.3.0 • Published 8 years ago
edit-file v0.3.0
edit-file
Edit (read, edit, write) a file in Node.js
npm install edit-fileAPI
editFile(file, edit=text=>text, callback=done)
fileis the filename path you want to edit. It may be relative or absolute.editis the editing function you use to change the text. The default returns the original text.callbackis a function to call after editing. The default throws errors and logs success.
Usage
const editFile = require("edit-file")editFile("example.txt")editFile("example.txt", text => text.trim())editFile("example.txt", text => text.trim(), err => {
if (err) throw err
// ...
})