https://github.com/dependents/node-detective-less
Grab the dependencies of a Less file by traversing its AST
https://github.com/dependents/node-detective-less
ast dependencies detective less module
Last synced: 7 days ago
JSON representation
Grab the dependencies of a Less file by traversing its AST
- Host: GitHub
- URL: https://github.com/dependents/node-detective-less
- Owner: dependents
- License: mit
- Created: 2017-02-11T17:03:14.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-02-01T13:31:59.000Z (5 months ago)
- Last Synced: 2025-06-08T00:42:20.673Z (23 days ago)
- Topics: ast, dependencies, detective, less, module
- Language: JavaScript
- Homepage:
- Size: 913 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @dependents/detective-less
[](https://github.com/dependents/node-detective-less/actions/workflows/ci.yml?query=branch%3Amain)
[](https://www.npmjs.com/package/@dependents/detective-less)
[](https://www.npmjs.com/package/@dependents/detective-less)> Find the dependencies of a less file
```sh
npm install @dependents/detective-less
```**Note:** This is specific to the .less style syntax.
It's the LESS counterpart to [detective](https://github.com/substack/node-detective), [detective-amd](https://github.com/dependents/node-detective-amd), and [detective-es6](https://github.com/dependents/node-detective-es6).
* The AST is generated using the [gonzales-pe](https://github.com/tonyganch/gonzales-pe) parser.
## Usage
```js
const fs = require('fs');
const detective = require('@dependents/detective-less');const content = fs.readFileSync('styles.less', 'utf8');
// list of imported file names (ex: 'foo.less', 'foo', etc)
const dependencies = detective(content);// or to also detect any url() references to images, fonts, etc.
const allDependencies = detective(content, { url: true });
```### Options
* `url` (optional): (`Boolean`) also detect any `url()` references to images, fonts, etc.
## License
[MIT](LICENSE)