1.0.0 • Published 8 years ago
css-detective v1.0.0
css-detective
Find all @import
s by walking the AST (similar to and inspired by detective, but for CSS)
example
strings
style.css:
@import 'a';
@import 'b';
@import 'c';
strings.js:
var cssDetective = require('css-detective')
var fs = require('fs')
var src = fs.readFileSync(__dirname + '/style.css')
var imports = cssDetective(src)
console.dir(imports)
output:
$ node examples/strings.js
[ 'a', 'b', 'c' ]
methods
var cssDetective = require('css-detective')
cssDetective(src, opts)
Give some source body src
, return an array of all the @import
s.
The options parameter opts
is passed along to cssDetective.find()
.
var found = cssDetective.find(src, opts)
Give some source body src
, return found
with:
found.strings
- an array of each string found in an@import
found.nodes
(whenopts.nodes === true
) - an array of AST nodes for each argument found in an@import
Optionally:
opts.nodes
- whentrue
, populatefound.nodes
opts.isImport(node)
- a function returning whether an AST node is an importopts.parse
- supply options directly to postcss
install
With npm do:
npm install css-detective
license
ISC
1.0.0
8 years ago