Skip to content

Commit c463dbe

Browse files
committed
Merge pull request #37 from kswedberg/glob-moduledirectories
Make globbed imports work for module directories, too.
2 parents 48e5ca6 + debda62 commit c463dbe

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ function parseStyles(styles, options, cb, importedFiles, ignoredAtRules, media,
109109
*/
110110
function parseGlob(atRule, options, imports) {
111111
var globPattern = atRule.params.replace(/['"]/g, "").replace(/(?:url\(|\))/g, "")
112+
var paths = options.path.concat(moduleDirectories)
112113
var files = []
113114
var dir = options.source && options.source.input && options.source.input.file ?
114115
path.dirname(path.resolve(options.root, options.source.input.file)) :
115116
options.root
116-
options.path.forEach(function(p) {
117+
paths.forEach(function(p) {
117118
p = path.resolve(dir, p)
118119
var globbed = glob.sync(path.join(p, globPattern))
119120
globbed.forEach(function(file) {

test/fixtures/glob.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@import "./foobar*.css";
2+
@import "by-hand/*.css";

test/fixtures/glob.expected.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
foobar{}
22
foobarbaz{}
3+
.byHand{}

test/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ test("@import", function(t) {
3737
compareFixtures(t, "ignore", "should ignore & adjust external import")
3838

3939
compareFixtures(t, "glob", "should handle a glob pattern", {
40+
root: __dirname,
4041
path: importsDir,
4142
glob: true
4243
})

0 commit comments

Comments
 (0)