Skip to content

Commit

Permalink
Provide explicit error message about bad input
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 committed Sep 30, 2015
1 parent 5516578 commit 8b2082d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var isglob = require('is-glob');
var arrify = require('arrify');
var isAbsolute = require('path-is-absolute');
var flatten = require('lodash.flatten');
var isString = require('is-string');

var NodeFsHandler = require('./lib/nodefs-handler');
var FsEventsHandler = require('./lib/fsevents-handler');
Expand Down Expand Up @@ -474,6 +475,10 @@ FSWatcher.prototype.add = function(paths, _origAdd, _internal) {
this.closed = false;
paths = flatten(arrify(paths));

if (!paths.every(isString)) {
throw new TypeError('Non-string provided as watch path');
}

if (cwd) paths = paths.map(function(path) {
if (isAbsolute(path)) {
return path;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"glob-parent": "^2.0.0",
"is-binary-path": "^1.0.0",
"is-glob": "^2.0.0",
"is-string": "^1.0.4",
"lodash.flatten": "^3.0.2",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.0.0"
Expand Down

0 comments on commit 8b2082d

Please sign in to comment.