https://github.com/ericadamski/env-filer
🗃 A tiny package to help manage dot files for you
https://github.com/ericadamski/env-filer
dotfiles files filesystem fs node node-js
Last synced: about 2 months ago
JSON representation
🗃 A tiny package to help manage dot files for you
- Host: GitHub
- URL: https://github.com/ericadamski/env-filer
- Owner: ericadamski
- Created: 2018-04-20T14:40:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T13:30:28.000Z (almost 7 years ago)
- Last Synced: 2024-12-23T09:36:12.409Z (5 months ago)
- Topics: dotfiles, files, filesystem, fs, node, node-js
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/env-filer
- Size: 96.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# env filer
🗃 A tiny package to help manage dot files for you
## Install
```
yarn add env-filer
```or npm
```
npm -i env-filer
```## Usage
```javascript
filer(name, [dir, [(options = { usePromises: false })]]);
```* **name** the name to use for your dot file
* ie. a name of `git-tokens` will label the file `.git-tokens`
* **dir** the location to write the dot file. _defaults to `~/.config`_
* **options** extra options, currently the only option is `usePromises: bool`
By default this library uses RxJS Observables. You can override that to output promises using the `usePromises` option.
```javascript
const filer = require('env-filer');const dotfile = filer('git-tokens');
// writes this to ~/.config/.git-tokens
dotfile
.write({ access_token: 'this is my token!' })
.subscribe(() => console.log('I have written!'));
// I have written// Read the data back
dotfile.read().subscribe(data => console.log(data));
// { access_token: 'this is my token!' }// Removes the file
dotfile.destroy().subscribe(console.log);
// true
```Using Promises
```javascript
const dotfile = filer('git-tokens', { usePromises: true });// Write the file
await dotfile.write({ access_token: 'this is my token!' });
// writes this to ~/.config/.git-tokens// Read the file
console.log(await dotfile.read());
// { access_token: 'this is my token!' }// Remove the file
console.log(await dotfile.destroy());
// true
```