Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to prevent path transformation #347

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ chokidar.watch('file', {
ignoreInitial: false,
followSymlinks: true,
cwd: '.',
preventPathTransformation: false,

usePolling: true,
alwaysStat: false,
Expand All @@ -108,6 +109,7 @@ chokidar.watch('file', {

ignorePermissionErrors: false,
atomic: true

});

```
Expand Down Expand Up @@ -140,6 +142,9 @@ symlinks themselves will be watched for changes instead of following
the link references and bubbling events through the link's path.
* `cwd` (no default). The base directory from which watch `paths` are to be
derived. Paths emitted with events will be relative to this.
* `preventPathTransformation` (default: `false`). When `true`, path is used literally
without any transformation. It's useful when the name contains special characters
like `*`, `(`, `)`, `{`, `}`...

#### Performance

Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function FSWatcher(_opts) {

if (undef('followSymlinks')) opts.followSymlinks = true;

// Prevent get non-magic path
if (undef('preventPathTransformation')) opts.preventPathTransformation = false;

this._isntIgnored = function(path, stat) {
return !this._isIgnored(path, stat);
}.bind(this);
Expand Down Expand Up @@ -239,7 +242,7 @@ FSWatcher.prototype._isIgnored = function(path, stats) {
// Returns object containing helpers for this path
FSWatcher.prototype._getWatchHelpers = function(path, depth) {
path = path.replace(/^\.[\/\\]/, '');
var watchPath = depth ? path : globparent(path);
var watchPath = depth || this.options.preventPathTransformation ? path : globparent(path);
var hasGlob = watchPath !== path;
var globFilter = hasGlob ? anymatch(path) : false;

Expand Down