https://github.com/admataz/node-fsdocs
node utility to handle saving text files
https://github.com/admataz/node-fsdocs
Last synced: over 1 year ago
JSON representation
node utility to handle saving text files
- Host: GitHub
- URL: https://github.com/admataz/node-fsdocs
- Owner: admataz
- License: isc
- Created: 2020-01-15T01:47:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T14:54:31.000Z (over 3 years ago)
- Last Synced: 2025-01-21T17:34:35.127Z (over 1 year ago)
- Language: JavaScript
- Size: 890 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# FSDocs
A node utility to handle saving text files.
This makes it easier to save text content to disk - for instance when a payload of content in an API request needs to be saved to the server as a static file.
## Usage
Instantiate the `FSDocs` class with the `basePath` for the save location - must be an absolute path
```js
const FSDocs = require('fsdocs')
const docsManager = new FSDocs('/path/to/save/loation)
```
### Create a file
`docsManager.createFile(path, name, ext, content)`
returns a promise with the absolute path of the created file
```js
await docsManager.createFile('path', 'file-name', '.txt', 'File Content')
```
### Read a file
`docsManager.readFile(path)`
returns a promise with the content of the file
```js
await docsManager.readFile('path/to/file.txt')
```
### Read a directory
`docsManager.listFiles(path)`
returns a promise with an array of filenames
```js
await docsManager.listFiles('path/to/dir')
```
### Update a file
`docsManager.updateFile(path, content)`
returns a promise with the absolute path of the created file
```js
await docsManager.updateFile('path/to/file.txt', 'Updated File Content')
```
### Delete a file
`docsManager.deleteFile(path)`
returns a promise with the absolute path of the deleted file
```js
await docsManager.deleteFile('path/to/file.txt')
```
## API documentation
Read the [JSDocs](/docs/index.html)
2020 Adam Davis ([ICS](./license.txt))
gi