Comments (21)
This is strange. Here is what you can do:
return watch({glob: <glob>}, function(files) {
console.log('Processing', files)
return files.pipe(using())
.pipe(debug());
});
This will catch changed events in this file.
from gulp-watch.
Unfortunately no differences. Same result.
This is my exact code:
watch({
glob: ['public/**/*.cshtml'],
timeout: 0,
verbose: false,
emitOnGlob: false
}, function (files, done) {
return files
.pipe(localizer.translateFile())
.pipe(gulp.dest(function (file) {
return path.dirname(file.path);
}))
.pipe(synchro(function () {
localizer.finalizeAndStat();
console.log('OK.');
done();
}))
});
(I tried also to remove all the logic and left only console output and got same results as well; timeout and emit are set for internal purposes and have no influence also).
and this code works excellent while no folders [with_name_like_this] exist in paths, but if I rename any folder to have brackets in the name, it fails.
from gulp-watch.
Could you test, that gaze is catching events?
var gaze = require('gaze');
gaze('public/**/*.cshtml', function(err, watcher) {
this.on('all', function(event, filepath) {
console.log(filepath + ' was ' + event);
});
});
from gulp-watch.
Yes, it catches. At least I see 'public[Web.UI][components]\framework\activity\list\list-view.cshtml was changed' with '[]' and without them.
from gulp-watch.
Thanks, this could be, because gulp.src is not emitting files properly. Could you check also this:
var gulp = require('gulp');
gulp.src('public[Web.UI][components]\framework\activity\list\list-view.cshtml')
.on('data', console.log);
It would be very helpful.
from gulp-watch.
It rather interesting. If I use
gulp.src("c:/tutorials/gulp_test/public/[Web.UI]/[components]/framework/activity/list/list-view.cshtml")
I see nothing. (I've tried different separators like /, , //)
But with
gulp.src(config.cshtmls)
where
cshtmls: ['public/**/list-view.cshtml']
it works and prints
<File "[Web.UI]\[components]\framework\activity\list\list-view.cshtml" <Buffer 40 75 73 69 6e 6...
from gulp-watch.
Yeah, that's strange.
@contra could you look at this?
from gulp-watch.
Moreover,
gulp.src('c:\\tutorials\\gulp_test\\public\\translations.cshtml')
works, but
gulp.src('c:\\tutorials\\gulp_test\\public\\[Web.UI]\\translations.cshtml')
does not (file exists, of course).
from gulp-watch.
Thanks for investigating, @lexey111! - I think this issue will be moved to vinyl-fs that provides src
method (or even deeper in glob-stream). As soon as it will be fixed gulp-watch will pick up those files.
from gulp-watch.
As far as I see now, problem is in Globule glob.sync that uses Glob module, that uses Minimatch, that treats path part like [Web.UI] as regexp, but it isn't. And somewhere during the processing escape characters are lost. For single files I can use workaround -
public/?Web.UI?/
but I don't know how to do this for glob patterns :(
from gulp-watch.
There is an easy way out - rename your directories 👍
from gulp-watch.
I can't - It's not MY directories, so have to use as is.
:(
from gulp-watch.
Does escaping [
with \[
helps? I think it could be patched in Minimatch.
from gulp-watch.
No, it does not.
Current state of investigation =) shows: it is required to change minimatch.js function parse, about line 650 such way:
case "[":
// swallow any state-tracking char before the [
// add this option
if (options.skipSquareBraces) {
continue;
}
and translate option through all the calls to force minimatch to skip processing [brackets].
But maybe other way exists... it is too low level patch, I'm afraid.Because minimatch is used multiple times/paths in the plugin's tree, and it has to be corrected everywhere...
from gulp-watch.
Because [ and ] are special characters in a glob, so if you use them directly you will have problems. If you really need a workaround replace them with * for the time being, the bug lies in minimatch
Also you could try skipSquareBraces: true
to src which might get passed down to minimatch
from gulp-watch.
The problem is: I can easily patch the minimatch.js module and can even make new fork, but minimatch is used in my project 12 times via dependencies of other modules. And it have 4 different versions (1.0.0, 0.2.14, 0.3.0, 0.4.0) so I don't know how to solve this problem... and I can't control the minimatch input to replace brackets by * or ?, because on my level I use gulp-watch -> that uses gaze -> that uses globule -> that uses glob (with wildcards) -> that uses minimatch...
from gulp-watch.
@lexey111 Send a PR to minimatch?
from gulp-watch.
No, I think it is not an issue of minimatch. Well, frankly speaking it is, but changes only in minimatch module can't solve the problem.
My current working solution (very stupid one, I'm afraid, but I have no time to dig deeper) is:
- Changes in Gaze.js, where Gaze.prototype.add = function(files, done) {
this._patterns = helper.unique.apply(null, [this._patterns, files]);
// add these lines to replace "[" in patterns by "?"
if (this.options && (this.options.skipSquareBraces === true)) {
for (var i = 0; i < this._patterns.length; i++) {
this._patterns[i] = this._patterns[i].replace(/\[/g, '?');
}
}
This will replace [-bracket and we'll have valid paths.
- Changes in index.js of gulp-watcher:
var nfs = require('fs');
...and near if(event === 'deleted') in duplex.gaze.on('all', ...
if (opts.gaze && (opts.gaze.skipSquareBraces === true)){
if (event === 'changed') {
nfs.createReadStream(filepath).on('data', function(file) {
var vfile = new vinyl({
path: filepath,
contents: file // it is a buffer
});
passThrough(vfile);
});
}
}
- Call gulp-watcher with this new option:
watch({
glob: <glob>,
gaze: {skipSquareBraces: true},
verbose: false
...
to has pass-through for changed file (otherwise no passthrough called). It works for me although I think other ways exist =)
from gulp-watch.
So I think 2 PRs needed:one to gaze and second one here, gulp-watch, but I'd prefer to escalate things to @floatdrop , 'cause I'm not sure my solution is the best one - especially for 2)
from gulp-watch.
@lexey111 minimatch should be able to escape characters though
from gulp-watch.
Issue moved to minimatch.
from gulp-watch.
Related Issues (20)
- Update anymatch version in package.json HOT 4
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- subfolders no longer updating the main style.scss file
- Watched unexpected filepath
- How to deal with changed files? HOT 2
- watch is not working correctly
- chokidar version 3 HOT 4
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- please publish the latest version to npm
- chokidar version is too low
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-watch.