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

Chokidar or Anymatch for glob patterns? #1122

Closed
2 of 10 tasks
zanona opened this issue Jun 6, 2016 · 3 comments
Closed
2 of 10 tasks

Chokidar or Anymatch for glob patterns? #1122

zanona opened this issue Jun 6, 2016 · 3 comments

Comments

@zanona
Copy link

zanona commented Jun 6, 2016

Issue details

The documentation states that for the files attribute under browsersync options, that I can use patterns following Anymatch api.

Browsersync can watch your files as you work. Changes you make will either be injected into the page (CSS & images) or will cause all browsers to do a full-page refresh. See anymatch for more information on glob patterns.

However when using functions or anything that is not a string within files[n].match, I get an error:

/Users/zanona/Developer/libs/bs-less/node_modules/chokidar/index.js:553
throw new TypeError('Non-string provided as watch path: ' + paths);

Steps to reproduce/test case

browsersync.init({
files: [                                                                
    {
        options: { ignoreInitial: false },
        match: [
            function (p) {
                return !/bower_components|node_modules/.test(p);
            },
            serverPath + '**.html'
        ],
        fn: onHTMLChange
    }
]
});

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.12.8]
  • Node [5.7.1]
  • Npm [3.6.0]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI
@shakyShane
Copy link
Contributor

match does not accept a function like this I'm afraid.

To exclude directories though, do the following.

browsersync.init({
    files: [
        {
            options: {
                ignoreInitial: false,
                ignored: [
                    /bower_components|node_modules/
                ]
            },
            match: [serverPath + '**.html'],
            fn: onHTMLChange
        }
    ]
});

@zanona
Copy link
Author

zanona commented Jun 7, 2016

@shakyShane Thanks I figured that along the way. But then is it a bug on the documentation, because anymatch accept this kind of pattern? I got a bit confused that it mentions anymatch at all instead chokidar?

@shakyShane
Copy link
Contributor

Removed from https://www.browsersync.io/docs/options

This was referenced Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants