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

globalDupe: true causes duplication error when watch is running #200

Open
jcrosetto opened this issue Sep 18, 2015 · 4 comments
Open

globalDupe: true causes duplication error when watch is running #200

jcrosetto opened this issue Sep 18, 2015 · 4 comments
Labels

Comments

@jcrosetto
Copy link

I was using gulp-stylint in conjunction with a watch to validate files when they change. Using globalDupe: true causes duplication errors to be thrown on every selector when changing a watched file even though none of the selectors are duplicated.

I attempted to figure out what was going on and it seems that adding the line "this.cache.sCache = {}" to resetOnChange fixes the issue.

@rossPatton
Copy link
Collaborator

thanks, that seems like an easy fix

@rossPatton rossPatton added the bug label Sep 18, 2015
@rossPatton
Copy link
Collaborator

should be resolved in 1.2.3

@jcrosetto
Copy link
Author

I updated to 1.2.3 and globalDupes: true is no longer working across watched files. I wasn't able to look into it that closely but it seems that when a file changes, resetOnChange gets called once for each file that is being watched causing sCache to get wiped in between each file check.

@rossPatton rossPatton reopened this Sep 24, 2015
@jcrosetto
Copy link
Author

It looks like resetOnChange is only called for a file after that file is checked for duplicates. So even if the sCache is cleared only once per file change, the first file checked after a change will throw duplicates errors every time.

I'm thinking it might be better to clear the sCache in duplicates.js the very first time it executes after a file changes. There might be a better way to do this but putting this near the top of the duplicates function seems to do the trick (it clears the cache if a file is in the cache and is not the most recent file checked for duplicates):

var dupCache = this.cache.sCache[this.state.context]
if (this.config.globalDupe &&
    dupCache &&
    dupCache[dupCache.length - 1] !== this.cache.file &&
    dupCache.indexOf(this.cache.file) !== -1)
{
    this.cache.sCache = {}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants