Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanve/edit-file
Edit a file in Node.js
https://github.com/ryanve/edit-file
filesystem node nodejs
Last synced: about 1 month ago
JSON representation
Edit a file in Node.js
- Host: GitHub
- URL: https://github.com/ryanve/edit-file
- Owner: ryanve
- License: other
- Created: 2017-09-16T21:53:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T06:42:06.000Z (about 7 years ago)
- Last Synced: 2024-10-09T16:04:20.323Z (about 1 month ago)
- Topics: filesystem, node, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/edit-file
- Size: 46.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# [`edit-file`](https://www.npmjs.com/package/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
```js
const editFile = require("edit-file")
``````js
editFile("example.txt")
``````js
editFile("example.txt", text => text.trim())
``````js
editFile("example.txt", text => text.trim(), err => {
if (err) throw err
// ...
})
```