0
npmモジュールのchokidarを使用して、少し問題があります。問題は、watcher.getWatched()の値がnullを返すことです。私はES6とこの演算子に関連する何かを逃していますか?Node.jsのES6とchokidarでの問題
私はエントリが
var chokidar = require('chokidar');
var FileSystemObject = require('../file-system-object');
class ChokidarWatcher {
constructor(studentPath) {
this.StudentPath = studentPath;
this.Watcher = chokidar.watch(this.StudentPath, {
// atomic: true,
alwaysStat: true,
usePolling: true,
ignoreInitial: true,
ignored: function (path, stat) {
if (stat) {
var isDir = stat.isDirectory();
var fso = new FileSystemObject(path, stat);
if (isDir) {
return (fso.name === 'node_modules' && studentPath === fso.dir) ||
fso.name === 'bower_components' || /[\/\\]\./.test(path)
} else {
return fso.name === '.DS_Store'
}
}
return false
}
});
}
GetMyWatcher() {
return this.Watcher;
};
GetWatched() {
var items = [];
var watched = this.Watcher.getWatched();
for (var dirpath in watched) {
items.push(new FileSystemObject(dirpath, true))
for (var i = 0; i < watched[dirpath].length; i++) {
var name = watched[dirpath][i];
var path = p.join(dirpath, name);
if (!watched[path]) {
// add file
items.push(new FileSystemObject(path, false))
}
}
}
return items
}
}
module.exports = ChokidarWatcher;
'getWatched' [決して' null'を返すように見える](https://github.com/paulmillr/chokidar/blob/master) /index.js#L682) – Bergi
空の配列を返します。申し訳ありません –