Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/frontainer/sync-dir
- Owner: frontainer
- License: mit
- Created: 2016-08-16T02:04:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-08T01:22:47.000Z (over 8 years ago)
- Last Synced: 2025-01-18T01:35:22.362Z (24 days ago)
- Topics: npm-scripts
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
});
```