-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the listener was truthy but NOT a function, fs.watchFile would throw an error through the EventEmitter. This caused a problem because it would only be thrown after the listener was started, which left the listener on. There should be no backwards compatability issues because the error was always thrown, just in a different manner. Also adds tests for this and other basic functionality. PR-URL: #2093 Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
1 parent
12bc397
commit 1afc0c9
Showing
2 changed files
with
24 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const assert = require('assert'); | ||
|
||
// Basic usage tests. | ||
assert.throws(function() { | ||
fs.watchFile('./some-file'); | ||
}, /watchFile requires a listener function/); | ||
|
||
assert.throws(function() { | ||
fs.watchFile('./another-file', {}, 'bad listener'); | ||
}, /watchFile requires a listener function/); | ||
|
||
assert.throws(function() { | ||
fs.watchFile(new Object(), function() {}); | ||
}, /Path must be a string/); |