https://github.com/kodedninja/datbot
Seed a DAT archive and trigger scripts on updates
https://github.com/kodedninja/datbot
Last synced: 9 months ago
JSON representation
Seed a DAT archive and trigger scripts on updates
- Host: GitHub
- URL: https://github.com/kodedninja/datbot
- Owner: kodedninja
- Created: 2019-05-06T18:07:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-06T18:09:54.000Z (about 7 years ago)
- Last Synced: 2025-01-02T22:30:14.913Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Seed a DAT archive and trigger scripts on updates
#### `Work In Progress`
## Installation
```
npm i datbot
```
## Usage
Use it as a CLI tool or from a Node program using the API.
```javascript
datbot('dat://dj837h....ew/', (path) => {
if (path.includes('content')) {
return [ 'npm run build' ]
}
}, {
output: '~/.tmp/'
})
```
## CLI
```
$ datbot [opts] [commands]
options
--help, -h show this help text
--output, -o tell datbot where to download the files
--verbose print to the console
--version, -v print version
example
$ datbot dat://dj837h....ew/ "git add . && git commit -m automatic"
```
## API
### `datbot(key, reducer(path), ?options, ?callback(exitCodes))`
Takes a Dat `key` that's forwarded to [`dat-node`](https://npmjs.com/package/dat-node) and a `reducer` function, that gets a `string` containing the path of the currently changed file and returns an `Array` of commands (`string`). The path here isn't reliable, when many files are changed at the same time.
Optionally you can pass a `callback` function, that gets called after each update containing an `Array` of exit codes.
Defaults of `options`:
```javascript
{
rate: 2500, // miliseconds between update calls
output: // output directory for the Dat archive
}
```