copy-and-watch
Advanced tools
Comparing version
18
index.js
@@ -13,3 +13,3 @@ const fs = require('fs'); | ||
['watch', 'clean'].forEach(key => { | ||
['watch', 'clean', 'skip-initial-copy'].forEach(key => { | ||
const index = args.indexOf(`--${key}`); | ||
@@ -27,2 +27,7 @@ if (index >= 0) { | ||
if (options['skip-initial-copy'] && !options['watch']) { | ||
console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied'.red); | ||
process.exit(1); | ||
} | ||
const target = args.pop(); | ||
@@ -91,9 +96,12 @@ const sources = args; | ||
// initial copy | ||
sources.forEach(s => glob.sync(s).forEach(copy)); | ||
if (!options['skip-initial-copy']) { | ||
sources.forEach(s => glob.sync(s).forEach(copy)); | ||
} | ||
// watch | ||
if (options.watch) { | ||
chokidar.watch(sources, { | ||
ignoreInitial: true | ||
}) | ||
chokidar | ||
.watch(sources, { | ||
ignoreInitial: true | ||
}) | ||
.on('ready', () => sources.forEach(s => console.log('[WATCH]'.yellow, s))) | ||
@@ -100,0 +108,0 @@ .on('add', copy) |
{ | ||
"name": "copy-and-watch", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Synchronize files or folders locally, with a watch option", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,2 +24,3 @@ # copy-and-watch | ||
--clean - clean target folder on start | ||
--skip-initial-copy - skip copying files initially, only copy if they change. Must be used with `--watch` argument. | ||
``` | ||
@@ -45,3 +46,6 @@ | ||
##### 0.1.4 | ||
- Added support for `—skip-initial-copy` argument (by mugli) | ||
##### 0.1.2 | ||
- Fixed copy on dir bug (by arnarthor) |
6515
7.69%98
7.69%50
8.7%