Skip to content

Commit

Permalink
Remove stat calls in aspy.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Apr 3, 2019
1 parent 8d1451d commit 7bfd263
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test.js
Expand Up @@ -25,16 +25,15 @@ const fs_unlink = promisify(fs.unlink);
const isTravisMac = process.env.TRAVIS && os === 'darwin';

// spyOnReady
const aspy = (watcher, eventName, spy) => {
const aspy = (watcher, eventName, spy=null, noStat=false) => {
if (typeof eventName !== 'string') {
throw new TypeError('aspy: eventName must be a String');
}
if (spy == null) spy = sinon.spy();
return new Promise((resolve, reject) => {
watcher.on('error', reject);
if (typeof eventName === 'string') {
watcher.on(eventName, spy);
}
watcher.on('ready', () => {
resolve(spy);
});
watcher.on('ready', () => { resolve(spy); });
watcher.on(eventName, noStat ? (path => spy(path)) : spy);
});
};

Expand Down Expand Up @@ -243,7 +242,7 @@ const runTests = function(baseopts) {
fs.mkdirSync(getFixturePath('h'), PERM_ARR);
fs.mkdirSync(getFixturePath('i'), PERM_ARR);

const spy = await aspy(watcher, 'add');
const spy = await aspy(watcher, 'add', null, true);

await write(test1Path, Date.now());
await write(test2Path, Date.now());
Expand Down

0 comments on commit 7bfd263

Please sign in to comment.