Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
detective-stylus
Advanced tools
The detective-stylus npm package is designed for analyzing Stylus files to find and extract import statements. This can be particularly useful in build tools and bundlers to determine dependencies between stylesheets, allowing for more efficient builds and updates. It parses Stylus syntax to identify `@import` and `@require` statements, enabling developers to programmatically understand dependencies and relationships within their Stylus stylesheets.
Extract import statements from Stylus files
This feature allows you to pass in a string of Stylus code and returns an array of strings representing the paths of files that are imported or required within that Stylus code. It's particularly useful for build tools that need to track file dependencies.
const detective = require('detective-stylus');
const content = '@import "./mixins.styl"';
const dependencies = detective(content);
console.log(dependencies); // ['./mixins.styl']
Similar to detective-stylus, postcss-import is used to process CSS files to find and inline import statements. While detective-stylus is specific to Stylus files, postcss-import works with CSS files and is part of the PostCSS ecosystem, offering a broader range of CSS processing capabilities.
rework-import is another CSS preprocessor tool that allows you to manage and inline your CSS imports. It's similar to detective-stylus in its goal of resolving file dependencies but operates within the context of the Rework CSS preprocessor system, making it more suitable for projects that are not specifically using Stylus.
Find the dependencies of a Stylus file
npm install detective-stylus
It's the Stylus counterpart to detective, detective-amd, detective-es6, and detective-sass.
Note: this detective uses a regex to find the @import
or @require
statements.
const detective = require('detective-stylus');
const content = fs.readFileSync('styles.styl', 'utf8');
// list of imported file names (ex: '_foo.styl', '_foo', etc)
const dependencies = detective(content);
FAQs
Get the dependencies of a Stylus file
The npm package detective-stylus receives a total of 1,096,712 weekly downloads. As such, detective-stylus popularity was classified as popular.
We found that detective-stylus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.