mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
31
node_modules/detective-sass/Readme.md
generated
vendored
Normal file
31
node_modules/detective-sass/Readme.md
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
### detective-sass [](https://npmjs.org/package/detective-sass) [](https://npmjs.org/package/detective-sass)
|
||||
|
||||
> Find the dependencies of a sass file
|
||||
|
||||
`npm install --save detective-sass`
|
||||
|
||||
**Note:** This is specific to the .sass style syntax of the Sass preprocessor. For SCSS support, please see [node-detective-scss](https://github.com/dependents/node-detective-scss)
|
||||
|
||||
It's the SASS counterpart to [detective](https://github.com/substack/node-detective), [detective-amd](https://github.com/mrjoelkemp/node-detective-amd), and [detective-es6](https://github.com/mrjoelkemp/node-detective-es6).
|
||||
|
||||
* The AST is generated using the [gonzales-pe](https://github.com/tonyganch/gonzales-pe) parser.
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
var detective = require('detective-sass');
|
||||
|
||||
var content = fs.readFileSync('styles.sass', 'utf8');
|
||||
|
||||
// list of imported file names (ex: '_foo.sass', '_foo', etc)
|
||||
var dependencies = detective(content);
|
||||
```
|
||||
|
||||
### Related
|
||||
|
||||
* [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.
|
||||
* [node-precinct](https://github.com/dependents/node-precinct) if you want to also support finding dependencies for JavaScript and other languages.
|
||||
|
||||
### License
|
||||
|
||||
MIT
|
64
node_modules/detective-sass/index.js
generated
vendored
Normal file
64
node_modules/detective-sass/index.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
const Walker = require('node-source-walk');
|
||||
const sass = require('gonzales-pe');
|
||||
const debug = require('debug')('detective-sass');
|
||||
|
||||
/**
|
||||
* Extract the @import statements from a given sass file's content
|
||||
*
|
||||
* @param {String} fileContent
|
||||
* @return {String[]}
|
||||
*/
|
||||
module.exports = function detective(fileContent) {
|
||||
if (typeof fileContent === 'undefined') { throw new Error('content not given'); }
|
||||
if (typeof fileContent !== 'string') { throw new Error('content is not a string'); }
|
||||
|
||||
let dependencies = [];
|
||||
let ast;
|
||||
|
||||
try {
|
||||
debug('content: ' + fileContent);
|
||||
ast = sass.parse(fileContent, { syntax: 'sass' });
|
||||
} catch (e) {
|
||||
debug('parse error: ', e.message);
|
||||
ast = {};
|
||||
}
|
||||
|
||||
detective.ast = ast;
|
||||
|
||||
const walker = new Walker();
|
||||
|
||||
walker.walk(ast, function(node) {
|
||||
if (!isImportStatement(node)) { return; }
|
||||
|
||||
dependencies = dependencies.concat(extractDependencies(node));
|
||||
});
|
||||
|
||||
return dependencies;
|
||||
};
|
||||
|
||||
function isImportStatement(node) {
|
||||
if (!node || node.type !== 'atrule') { return false; }
|
||||
if (!node.content.length || node.content[0].type !== 'atkeyword') { return false; }
|
||||
|
||||
var atKeyword = node.content[0];
|
||||
|
||||
if (!atKeyword.content.length) { return false; }
|
||||
|
||||
var importKeyword = atKeyword.content[0];
|
||||
|
||||
if (importKeyword.type !== 'ident' || importKeyword.content !== 'import') { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function extractDependencies(importStatementNode) {
|
||||
return importStatementNode.content
|
||||
.filter(function(innerNode) {
|
||||
return innerNode.type === 'string' || innerNode.type === 'ident';
|
||||
})
|
||||
.map(function(identifierNode) {
|
||||
return identifierNode.content.replace(/["']/g, '');
|
||||
});
|
||||
}
|
67
node_modules/detective-sass/package.json
generated
vendored
Normal file
67
node_modules/detective-sass/package.json
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"detective-sass@3.0.1",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "detective-sass@3.0.1",
|
||||
"_id": "detective-sass@3.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-oSbrBozRjJ+QFF4WJFbjPQKeakoaY1GiR380NPqwdbWYd5wfl5cLWv0l6LsJVqrgWfFN1bjFqSeo32Nxza8Lbw==",
|
||||
"_location": "/detective-sass",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "detective-sass@3.0.1",
|
||||
"name": "detective-sass",
|
||||
"escapedName": "detective-sass",
|
||||
"rawSpec": "3.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/precinct"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/detective-sass/-/detective-sass-3.0.1.tgz",
|
||||
"_spec": "3.0.1",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"author": {
|
||||
"name": "Joel Kemp",
|
||||
"email": "joel@mrjoelkemp.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mrjoelkemp/node-detective-sass/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"gonzales-pe": "^4.2.3",
|
||||
"node-source-walk": "^4.0.0"
|
||||
},
|
||||
"description": "Find the dependencies of a sass file",
|
||||
"devDependencies": {
|
||||
"mocha": "^5.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0"
|
||||
},
|
||||
"homepage": "https://github.com/mrjoelkemp/node-detective-sass",
|
||||
"keywords": [
|
||||
"detective",
|
||||
"sass",
|
||||
"ast",
|
||||
"dependencies"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "detective-sass",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mrjoelkemp/node-detective-sass.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/test.js"
|
||||
},
|
||||
"version": "3.0.1"
|
||||
}
|
Reference in New Issue
Block a user