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

Can't exclude files by directory #14

Open
moatra opened this issue Jul 3, 2014 · 4 comments
Open

Can't exclude files by directory #14

moatra opened this issue Jul 3, 2014 · 4 comments

Comments

@moatra
Copy link

moatra commented Jul 3, 2014

For files that I can't load from WebJars, I typically commit them to my assets/javascripts/vendor directory. Not all of them will pass jshint's tests, so I'd like to exclude them from being linted.

I've tried a couple of approaches:

excludeFilter in (Assets, JshintKeys.jshint) := GlobFilter("*/vendor/*")

This doesn't work, since the filtering appears to work on file names rather than full paths.

managedSourceDirectories in (Assets, JshintKeys.jshint) := List((sourceDirectory in Compile).value / "assets" / "javascripts" / "vendor")

The only thing that seems to work is providing a pattern filter for excludeFilter that explicitly enumerates the files contained in the vendor directory, but this is ugly and doesn't scale well.

Is there a better option available?

Edit: Researching sbt's file filters further, I came up with the following. Not pretty, but I guess it gets the job done.

excludeFilter in (Assets, JshintKeys.jshint) := new FileFilter{ def accept(f: File) = ".*/vendor/.*".r.pattern.matcher(f.getAbsolutePath).matches }
@huntc
Copy link

huntc commented Jul 3, 2014

Put them in the public folder...?

@magnusart
Copy link

Then Concat won't find the files (since they're not under assets). My scenario is to take all the files and concat them into a vendor.js-file.

@micmro
Copy link

micmro commented Sep 11, 2014

Thanks @moatra, your suggestion worked for us. Tough it would be nice to be able to add them just like files.

E.g. using a syntax like:

excludeFilter in (Import.Assets, JshintKeys.jshint) := "*/lib/*"

instead of:

excludeFilter in (Assets, JshintKeys.jshint) := new FileFilter{
    def accept(f: File) = ".*/lib/.*".r.pattern.matcher(f.getAbsolutePath).matches
}

@dwickern
Copy link

I used this setting to exclude the public folder

excludeFilter in (Assets, JshintKeys.jshint) := {
  val public = (baseDirectory.value / "public").getCanonicalPath
  new SimpleFileFilter(_.getCanonicalPath startsWith public)
}

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

5 participants