Skip to content

Commit

Permalink
fix: url()s in @value definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed May 14, 2018
1 parent f305c9e commit 6293690
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ function detective(src, options: detective.Options = { url: false }) {
debug(`found %s of %s`, '@value with import', file);
}
}
if (options.url && isUrlNode(lastNode)) {
file = getValueOrUrl(lastNode);
if (file) {
debug(`found %s of %s`, 'url() with import', file);
}
}
}
file && references.push(file);
});
if (options.url) {
root.walkDecls(decl => {
const { nodes } = parseValue(decl.value);
references = references.concat(
nodes.filter(isUrlNode).map(getValueOrUrl)
);
const files = nodes.filter(isUrlNode).map(getValueOrUrl);
if (files) {
files.forEach(file =>
debug(`found %s of %s`, 'url() with import', file)
);
references = references.concat(files);
}
});
}
return references;
Expand Down
4 changes: 4 additions & 0 deletions tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ describe('node-detective-postcss', () => {
{ url: true }
);
});

it('finds url() in @value definitions', () => {
assert('@value x: url(bummer.png)', ['bummer.png'], { url: true });
});
});

describe('error handling', () => {
Expand Down

0 comments on commit 6293690

Please sign in to comment.