Skip to content

Support file globbing #7

Closed
robwierzbowski opened this Issue May 19, 2013 · 15 comments

4 participants

@robwierzbowski

It would be convenient and less fragile if src supported globbing. Since csscss only supports explicitly named files, node would have to expand the glob and then pass the resulting files to the csscss gem.

@peterkeating
Owner

Excellent suggestion! Will definitely have a good look at this! Thanks ever so much for your input.

@peterkeating
Owner

Went to implement this, added an example of using a glob pattern to the grunt file, and it turned out that it works straight out of the box. Check out the example in the gruntfile.js file to see if that is what your after? If not then I would be happy to work on an alternative solution, but it does look like CSSCSS supports glob patterns.

@robwierzbowski

Huh, when I use the pattern app/_scss/*.scss I get an error:

/Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/sass-3.2.9/lib/sass/engine.rb:223:in `read': No such file or directory - app/_scss/*.scss (Errno::ENOENT)
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/sass-3.2.9/lib/sass/engine.rb:223:in `for_file'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:180:in `load_sass_file'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:30:in `block in execute'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:24:in `map'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:24:in `execute'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:17:in `run'

    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/lib/csscss/cli.rb:203:in `run'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/gems/csscss-1.3.1/bin/csscss:4:in `<top (required)>'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/bin/csscss:19:in `load'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/bin/csscss:19:in `<main>'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/robw/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'

The app/_scss directory has two .scss files in it.

@robwierzbowski

Tested with scss and css files, on master and 5.0 branches.

@peterkeating
Owner

Ah okay, I was just doing it with *.css, although gave it a try with *.scss and it worked for me.

I have added a new branch with an example of a glob pattern with Sass files.

This might be an issue with CSSCSS.

/cc @zmoazeni

@robwierzbowski

The error is a Sass error -- it looks like Sass is trying to read the glob as a file. Not familiar with the inner workings of csscss, so I'm unsure where Sass being executed comes into play. What version of Sass and CSSCSS are you using?

@peterkeating
Owner

CSSCSS 1.3.1, Sass 3.2.7, Ruby 1.9.3p327 & I am on a Windows machine.

@peterkeating
Owner

Just updated to the latest version of Sass (3.2.9) and it still works for my end... bit of a head scratcher!

@zmoazeni

csscss doesn't do anything explicitly with globbing. It depends on the shell to pass it multiple files.

@peterkeating
Owner

So with the glob patterns being shell dependant, I have gone ahead and implemented glob patterns in the grunt task. Would be good if you could give it a try @robwierzbowski and see if it is what you are after.

@robwierzbowski

I haven't forgotten about checking this, just been really busy the last (9?!) days. Still stoked on this feature; I'll give it a test this week.

@peterkeating
Owner

Cool, any luck with this? Will look to publish the new version at some point this week :)

@robwierzbowski

Had a chance to test today, works great! Tried a bunch of globs, including wildcards and bracket expansion (<%= yeoman.app %>/**/*.{,s}css), all worked without error.

Thanks again for coding this up, and sorry for the testing delay.

@peterkeating
Owner

No worries, thanks for the suggestion :)

@jeffbyrnes

As a heads-up, this seems to still have issues, similar to @robwierzbowski's comment above, when used with LESS.

Example output:

♠  grunt csscss
Running "csscss:dist" (csscss) task
less/**/*.less
/usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/open-uri.rb:35:in `initialize': No such file or directory - less/**/*.less (Errno::ENOENT)
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/open-uri.rb:35:in `open'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/1.9.1/open-uri.rb:35:in `open'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:195:in `load_css_file'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:190:in `load_less_file'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:32:in `block in execute'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:24:in `map'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:24:in `execute'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:17:in `run'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/lib/csscss/cli.rb:200:in `run'
    from /usr/local/var/rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/csscss-1.3.2/bin/csscss:4:in `<top (required)>'
    from /usr/local/var/rbenv/versions/1.9.3-p429/bin/csscss:23:in `load'
    from /usr/local/var/rbenv/versions/1.9.3-p429/bin/csscss:23:in `<main>'


Done, without errors.

Ruby 1.9.3p429, lessc 1.3.3 (LESS Compiler) [Ruby] 2.3.2, therubyracer 0.11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.