node-watch
Advanced tools
Comparing version 0.6.3 to 0.6.4
# Changelog | ||
## 0.6.4 | ||
* Fix `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM` error for Node v14. | ||
# Changelog | ||
## 0.6.3 | ||
@@ -4,0 +10,0 @@ |
@@ -82,3 +82,18 @@ var fs = require('fs'); | ||
var options = { recursive: true }; | ||
var watcher = fs.watch(parent, options); | ||
var watcher; | ||
try { | ||
watcher = fs.watch(parent, options); | ||
} catch (e) { | ||
if (e.code == 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM') { | ||
return fn(IS_SUPPORT = false); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
if (!watcher) { | ||
return false; | ||
} | ||
var timer = setTimeout(function() { | ||
@@ -85,0 +100,0 @@ watcher.close(); |
@@ -329,4 +329,2 @@ var fs = require('fs'); | ||
var opts = Object.assign({}, options, { | ||
// no need to watch recursively | ||
recursive: false, | ||
// no filter for single file | ||
@@ -337,2 +335,5 @@ filter: null, | ||
// no need to watch recursively | ||
delete opts.recursive; | ||
var watcher = fs.watch(parent, opts); | ||
@@ -367,3 +368,3 @@ this.add(watcher, { | ||
if (!has) { | ||
Object.assign(opts, { recursive: false }); | ||
delete opts.recursive; | ||
} | ||
@@ -370,0 +371,0 @@ |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"bugs": { | ||
@@ -17,0 +17,0 @@ "url": "https://github.com/yuanchuan/node-watch/issues" |
@@ -200,2 +200,2 @@ # node-watch [![Status](https://travis-ci.org/yuanchuan/node-watch.svg?branch=master)](https://travis-ci.org/yuanchuan/node-watch "See test builds") | ||
Copyright (c) 2012-2018 [yuanchuan](https://github.com/yuanchuan) | ||
Copyright (c) 2020 [yuanchuan](https://github.com/yuanchuan) |
@@ -252,2 +252,18 @@ var assert = require('assert'); | ||
it('should be able to handle many events on deleting', function(done) { | ||
var dir = 'home/a'; | ||
var fpath = tree.getPath(dir); | ||
var names = tree.newRandomFiles(dir, 300); | ||
var count = 0; | ||
watcher = watch(fpath, function(evt, name) { | ||
count += 1; | ||
if (count == names.length) done(); | ||
}); | ||
watcher.on('ready', function() { | ||
names.forEach(tree.remove.bind(tree)); | ||
}); | ||
}); | ||
it('should identify `update` event', function(done) { | ||
@@ -254,0 +270,0 @@ var file = 'home/a/file1'; |
@@ -71,4 +71,4 @@ var fs = require('fs-extra'); | ||
return { | ||
getPath: function(fpath) { | ||
return path.join(root, fpath); | ||
getPath: function(fpath, sub) { | ||
return path.join(root, fpath, sub || ''); | ||
}, | ||
@@ -93,2 +93,12 @@ modify: function(fpath, delay) { | ||
}, | ||
newRandomFiles: function(fpath, count) { | ||
var names = []; | ||
for (var i = 0; i < count; ++i) { | ||
var name = Math.random().toString().substr(2); | ||
var filePath = this.getPath(fpath, name); | ||
fs.ensureFileSync(filePath); | ||
names.push(path.join(fpath, name)); | ||
} | ||
return names; | ||
}, | ||
newSymLink: function(src, dist) { | ||
@@ -95,0 +105,0 @@ fs.ensureSymlinkSync( |
Sorry, the diff of this file is not supported yet
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
52600
1333