Skip to content

Commit

Permalink
Resolve globs with respect to opts.cwd
Browse files Browse the repository at this point in the history
Closes #185
  • Loading branch information
floatdrop committed Jul 15, 2015
1 parent d71486c commit 3837ab5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Expand Up @@ -20,9 +20,6 @@ module.exports = function (globs, opts, cb) {
throw new PluginError('gulp-watch', 'glob should be String or Array, not ' + (typeof globs));
}

// Remove ./ from globs
globs = globs.map(function (g) { return path.resolve(g); });

if (typeof opts === 'function') {
cb = opts;
opts = {};
Expand All @@ -31,6 +28,11 @@ module.exports = function (globs, opts, cb) {
opts = opts || {};
cb = cb || function () {};

// Remove ./ from globs
globs = globs.map(function (g) {
return path.resolve(opts.cwd || process.cwd(), g);
});

opts.events = opts.events || ['add', 'change', 'unlink'];
if (opts.ignoreInitial === undefined) { opts.ignoreInitial = true; }
opts.readDelay = opts.readDelay || 10;
Expand All @@ -51,7 +53,7 @@ module.exports = function (globs, opts, cb) {

['add', 'change', 'unlink', 'addDir', 'unlinkDir', 'error', 'ready', 'raw']
.forEach(function (ev) {
watcher.on(ev, outputStream.emit.bind(outputStream, ev));
watcher.on(ev, outputStream.emit.bind(outputStream, ev));
});

outputStream.add = watcher.add.bind(watcher);
Expand Down

0 comments on commit 3837ab5

Please sign in to comment.