1.0.0 • Published 10 years ago
css-detective v1.0.0
css-detective
Find all @imports 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 @imports.
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@importfound.nodes(whenopts.nodes === true) - an array of AST nodes for each argument found in an@import
Optionally:
opts.nodes- whentrue, populatefound.nodesopts.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-detectivelicense
ISC
1.0.0
10 years ago