Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detective-sass

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-sass - npm Package Compare versions

Comparing version 4.0.1 to 4.1.0

26

index.js

@@ -13,8 +13,12 @@ 'use strict';

* @param {String} fileContent
* @param {Object} options
* @param {Boolean} options.url - detect any url() references to images, fonts, etc.
* @return {String[]}
*/
module.exports = function detective(fileContent) {
module.exports = function detective(fileContent, options) {
if (typeof fileContent === 'undefined') throw new Error('content not given');
if (typeof fileContent !== 'string') throw new Error('content is not a string');
const isEnabledUrl = options && options.url;
let dependencies = [];

@@ -35,5 +39,11 @@ let ast = {};

walker.walk(ast, (node) => {
if (!isImportStatement(node)) return;
if (isImportStatement(node)) {
dependencies = dependencies.concat(extractDependencies(node));
return;
}
dependencies = dependencies.concat(extractDependencies(node));
if (isEnabledUrl && isUrlNode(node)) {
dependencies = dependencies.concat(extractUriDependencies(node));
return;
}
});

@@ -64,1 +74,11 @@

}
function isUrlNode(node) {
return node.type === 'uri';
}
function extractUriDependencies(importStatementNode) {
return importStatementNode.content
.filter((innerNode) => innerNode.type === 'string' || innerNode.type === 'ident' || innerNode.type === 'raw')
.map((identifierNode) => identifierNode.content.replace(/["']/g, ''));
}

2

package.json
{
"name": "detective-sass",
"version": "4.0.1",
"version": "4.1.0",
"description": "Find the dependencies of a sass file",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -25,2 +25,5 @@ ### detective-sass [![CI](https://img.shields.io/github/workflow/status/dependents/node-detective-sass/CI/main?label=CI&logo=github)](https://github.com/dependents/node-detective-sass/actions/workflows/ci.yml?query=branch%3Amain) [![npm](https://img.shields.io/npm/v/detective-sass)](https://www.npmjs.com/package/detective-sass) [![npm](https://img.shields.io/npm/dm/detective-sass)](https://www.npmjs.com/package/detective-sass)

const dependencies = detective(content);
// or to also detect any url() references to images, fonts, etc.
const allDependencies = detective(content, { url: true });
```

@@ -27,0 +30,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc