Skip to content

Commit

Permalink
Merge pull request #37 from kswedberg/glob-moduledirectories
Browse files Browse the repository at this point in the history
Make globbed imports work for module directories, too.
  • Loading branch information
MoOx committed Apr 19, 2015
2 parents 48e5ca6 + debda62 commit c463dbe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ function parseStyles(styles, options, cb, importedFiles, ignoredAtRules, media,
*/
function parseGlob(atRule, options, imports) {
var globPattern = atRule.params.replace(/['"]/g, "").replace(/(?:url\(|\))/g, "")
var paths = options.path.concat(moduleDirectories)
var files = []
var dir = options.source && options.source.input && options.source.input.file ?
path.dirname(path.resolve(options.root, options.source.input.file)) :
options.root
options.path.forEach(function(p) {
paths.forEach(function(p) {
p = path.resolve(dir, p)
var globbed = glob.sync(path.join(p, globPattern))
globbed.forEach(function(file) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/glob.css
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import "./foobar*.css";
@import "by-hand/*.css";
1 change: 1 addition & 0 deletions test/fixtures/glob.expected.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
foobar{}
foobarbaz{}
.byHand{}
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ test("@import", function(t) {
compareFixtures(t, "ignore", "should ignore & adjust external import")

compareFixtures(t, "glob", "should handle a glob pattern", {
root: __dirname,
path: importsDir,
glob: true
})
Expand Down

0 comments on commit c463dbe

Please sign in to comment.