Giter Site home page Giter Site logo

Comments (21)

floatdrop avatar floatdrop commented on August 17, 2024

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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

floatdrop avatar floatdrop commented on August 17, 2024

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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

floatdrop avatar floatdrop commented on August 17, 2024

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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

floatdrop avatar floatdrop commented on August 17, 2024

Yeah, that's strange.

@contra could you look at this?

from gulp-watch.

lexey111 avatar lexey111 commented on August 17, 2024

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.

floatdrop avatar floatdrop commented on August 17, 2024

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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

floatdrop avatar floatdrop commented on August 17, 2024

There is an easy way out - rename your directories 👍

from gulp-watch.

lexey111 avatar lexey111 commented on August 17, 2024

I can't - It's not MY directories, so have to use as is.
:(

from gulp-watch.

floatdrop avatar floatdrop commented on August 17, 2024

Does escaping [ with \[ helps? I think it could be patched in Minimatch.

from gulp-watch.

lexey111 avatar lexey111 commented on August 17, 2024

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.

yocontra avatar yocontra commented on August 17, 2024

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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

yocontra avatar yocontra commented on August 17, 2024

@lexey111 Send a PR to minimatch?

from gulp-watch.

lexey111 avatar lexey111 commented on August 17, 2024

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:

  1. 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.

  1. 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);
            });
        }
    }
  1. 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.

lexey111 avatar lexey111 commented on August 17, 2024

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.

yocontra avatar yocontra commented on August 17, 2024

@lexey111 minimatch should be able to escape characters though

from gulp-watch.

floatdrop avatar floatdrop commented on August 17, 2024

Issue moved to minimatch.

from gulp-watch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.