edit-file

0.3.0 • Public • Published

edit-file

Edit (read, edit, write) a file in Node.js

npm install edit-file

API

editFile(file, edit=text=>text, callback=done)

  • file is the filename path you want to edit. It may be relative or absolute.
  • edit is the editing function you use to change the text. The default returns the original text.
  • callback is 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
  // ...
})

Package Sidebar

Install

npm i edit-file

Weekly Downloads

37

Version

0.3.0

License

CC0-1.0

Last publish

Collaborators

  • ryanve