detective-stylus
Version:
Get the dependencies of a Stylus file
44 lines (29 loc) • 1.34 kB
Markdown
# detective-stylus
[](https://github.com/dependents/node-detective-stylus/actions/workflows/ci.yml?query=branch%3Amain)
[](https://www.npmjs.com/package/detective-stylus)
[](https://www.npmjs.com/package/detective-stylus)
> Find the dependencies of a Stylus file
```sh
npm install detective-stylus
```
It's the Stylus counterpart to
[detective](https://github.com/substack/node-detective),
[detective-amd](https://github.com/dependents/node-detective-amd),
[detective-es6](https://github.com/dependents/node-detective-es6),
and [detective-sass](https://github.com/dependents/node-detective-sass).
Note: this detective uses a regex to find the `@import` or `@require` statements.
## Usage
### ESM
```js
import fs from 'node:fs';
import detective from 'detective-stylus';
const content = fs.readFileSync('styles.styl', 'utf8');
// list of imported file names (ex: '_foo.styl', '_foo', etc)
const dependencies = detective(content);
```
### CommonJS
```js
const { default: detective } = require('detective-stylus');
```
## License
[MIT](LICENSE)