Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/frontainer/sync-dir

sync directory in package.json
https://github.com/frontainer/sync-dir

npm-scripts

Last synced: 5 days ago
JSON representation

sync directory in package.json

Awesome Lists containing this project

README

        

# sync-dir

sync directory in package.json

## Require

Node.js =< 5.0

## Install

```
npm i sync-dir --save-dev
```

## Usage

Add 'sync' property to package.json.

```
{
"sync": {
"/path/to/source/**/*": "/path/to/dest"
}
}
```

Or create `sync.conf.js`. When, execute `sync-dir` command with `-c ./sync.conf.js` option.

```
module.exports = {
"/path/to/source/**/*": "/path/to/dest"
};
```

### CLI

```
# from package.json's sync property.
$ sync-dir

# watch files
$ sync-dir -w

# from `sync.conf.js`
$ sync-dir -c ./sync.conf.js
```

### Options

- -w, --watch: watch directories
- -c, --config: load sync files config
- -v, --version version: show version number
- -h, --help help: show help

### Module

```
const syncDir = require('sync-dir');
syncDir.copy({
'/path/to/source/**/*': '/path/to/dest'
}).then(() => {
// done
}).catch(() => {
// error
});
```

```
const syncDir = require('sync-dir');
const DATA = {
'/path/to/source/**/*': '/path/to/dest'
};
let files = syncDir.getFiles(DATA);
syncDir.watch(files,() => {
syncDir.copy(DATA);
});
```