@erickmerchant/conditional-watch
Advanced tools
Comparing version 2.0.1 to 2.1.0
14
index.js
const watch = require('recursive-watch') | ||
const debounce = require('debounce-fn') | ||
module.exports = function (conditional, directory, fn, options) { | ||
module.exports = function (conditional, targets, fn, options) { | ||
if (!Array.isArray(targets)) { | ||
targets = [targets] | ||
} | ||
if (conditional) { | ||
@@ -13,6 +17,8 @@ let files = [] | ||
watch(directory, function (file) { | ||
files.push(file) | ||
targets.forEach(function (target) { | ||
watch(target, function (file) { | ||
files.push(file) | ||
debounced() | ||
debounced() | ||
}) | ||
}) | ||
@@ -19,0 +25,0 @@ } |
{ | ||
"name": "@erickmerchant/conditional-watch", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Watch using recursive-watch or not", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
26
test.js
@@ -70,1 +70,27 @@ const test = require('tape') | ||
}) | ||
test('true - multiple', function (t) { | ||
mockery.enable(mockerySettings) | ||
t.plan(2) | ||
let directories = [] | ||
mockery.registerMock('debounce-fn', function (fn, options) { | ||
return fn | ||
}) | ||
mockery.registerMock('recursive-watch', function (directory, fn) { | ||
directories.push(directory) | ||
}) | ||
require('./index')(true, ['./foo', './bar'], function (files) { | ||
t.ok(1) | ||
t.deepEqual(directories, ['./foo', './bar']) | ||
}) | ||
mockery.disable() | ||
mockery.deregisterAll() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4096
86