detective-scss
Advanced tools
Comparing version 3.1.1 to 4.0.0
15
index.js
@@ -12,3 +12,3 @@ 'use strict'; | ||
* | ||
* @param {String} fileContent | ||
* @param {String} content | ||
* @param {Object} options | ||
@@ -18,12 +18,11 @@ * @param {Boolean} options.url - detect any url() references to images, fonts, etc. | ||
*/ | ||
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'); | ||
module.exports = function detective(content, options) { | ||
if (content === undefined) throw new Error('content not given'); | ||
if (typeof content !== 'string') throw new Error('content is not a string'); | ||
const isUrlEnabled = options && options.url; | ||
let ast = {}; | ||
try { | ||
debug('content: %s', fileContent); | ||
ast = sass.parse(fileContent, { syntax: 'scss' }); | ||
debug('content: %s', content); | ||
ast = sass.parse(content, { syntax: 'scss' }); | ||
} catch (error) { | ||
@@ -44,3 +43,3 @@ debug('parse error: %s', error.message); | ||
if (isUrlEnabled && node.type === 'uri') { | ||
if (options?.url && node.type === 'uri') { | ||
dependencies = [...dependencies, ...extractUriDependencies(node)]; | ||
@@ -47,0 +46,0 @@ } |
{ | ||
"name": "detective-scss", | ||
"version": "3.1.1", | ||
"version": "4.0.0", | ||
"description": "Find the dependencies of an scss file", | ||
@@ -34,7 +34,7 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=14" | ||
}, | ||
"dependencies": { | ||
"gonzales-pe": "^4.3.0", | ||
"node-source-walk": "^5.0.1" | ||
"node-source-walk": "^6.0.0" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
"uvu": "^0.5.6", | ||
"xo": "^0.52.4" | ||
"xo": "^0.54.2" | ||
}, | ||
@@ -47,0 +47,0 @@ "xo": { |
@@ -1,3 +0,7 @@ | ||
### detective-scss [![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-scss/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-scss/actions/workflows/ci.yml?query=branch%3Amain) [![npm version](https://img.shields.io/npm/v/detective-scss?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-scss) [![npm downloads](https://img.shields.io/npm/dm/detective-scss)](https://www.npmjs.com/package/detective-scss) | ||
# detective-scss | ||
[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-detective-scss/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-detective-scss/actions/workflows/ci.yml?query=branch%3Amain) | ||
[![npm version](https://img.shields.io/npm/v/detective-scss?logo=npm&logoColor=fff)](https://www.npmjs.com/package/detective-scss) | ||
[![npm downloads](https://img.shields.io/npm/dm/detective-scss)](https://www.npmjs.com/package/detective-scss) | ||
> Find the dependencies of an scss file | ||
@@ -15,3 +19,3 @@ | ||
### Usage | ||
## Usage | ||
@@ -31,3 +35,3 @@ ```js | ||
### Related | ||
## Related | ||
@@ -37,4 +41,4 @@ * [node-sass-lookup](https://github.com/dependents/node-sass-lookup) if you want to map a sass/scss dependency to a file on your filesystem. | ||
### License | ||
## License | ||
[MIT](LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42
6592
55
+ Addednode-source-walk@6.0.2(transitive)
- Removednode-source-walk@5.0.2(transitive)
Updatednode-source-walk@^6.0.0