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

grunt sloc ignores files - Maybe side effect fix for #14 #24

Open
kayomarz opened this issue Jul 4, 2016 · 1 comment
Open

grunt sloc ignores files - Maybe side effect fix for #14 #24

kayomarz opened this issue Jul 4, 2016 · 1 comment

Comments

@kayomarz
Copy link

kayomarz commented Jul 4, 2016

grunt sloc seems to be ignoring many files which are included in the src pattern.

To be more specific, here's my sloc config:

sloc: {
  'mylib': {
    files: {
      'mylib': ['*.js']
    }
  }
}

and here's my directory structure:

mylib/
mylib/one.js
mylib/two.js
mylib/util
mylib/util/three.js

number of files read by grunt sloc is zero. It should have been 2 files.

The problem does not occur after commenting out these lines related to solving issue #14:

    #14 negate match
     if (grunt.file.match(srcFilters, [f]).length === 0) {
        return;
     }

In the above code, f is an absolute path which seems to be the reason of the problem. One solution would have been to replace the above if condition with something like:

     var relPath = path.relative(path.join(process.cwd(), dest), f);
     if (grunt.file.match(srcFilters, [relPath ]).length === 0) {    

However after doing the above fix, src patterns such as **.js do not work.

I would think that instead of using readDir.readSync grunt's files.src.filter would do a better job. If you'd like to try this way, I can try to send a PR over the weekend.

@kayomarz kayomarz changed the title Side effects of fix for issue #14 grunt sloc ignores files - Maybe side effect fix for #14 Jul 4, 2016
@MichaelPote
Copy link

I also experience this issue with it returning 0 files found. I commented out the lines above and it worked again. Definitely a bug.

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