This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

24
node_modules/detective-less/Readme.md generated vendored Normal file
View File

@ -0,0 +1,24 @@
### detective-less [![npm](http://img.shields.io/npm/v/detective-less.svg)](https://npmjs.org/package/detective-less) [![npm](http://img.shields.io/npm/dm/detective-less.svg)](https://npmjs.org/package/detective-less)
> Find the dependencies of a less file
`npm install --save detective-less`
This is a fork of a package by [mrjoelkemp](https://github.com/mrjoelkemp/) given a lack of a less detective, it is the counterpart to [detective](https://github.com/substack/node-detective), [detective-amd](https://github.com/mrjoelkemp/node-detective-amd), [detective-sass](https://github.com/mrjoelkemp/node-detective-sass), [detective-scss](https://github.com/mrjoelkemp/node-detective-scss) 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-less');
var content = fs.readFileSync('styles.less', 'utf8');
// list of imported file names (ex: 'foo.less', 'foo', etc)
var dependencies = detective(content);
```
### License
MIT

64
node_modules/detective-less/index.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
'use strict';
const Walker = require('node-source-walk');
const gonzales = require('gonzales-pe');
const debug = require('debug')('detective-less');
/**
* Extract the @import statements from a given less 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 = gonzales.parse(fileContent, { syntax: 'less' });
} 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; }
const atKeyword = node.content[0];
if (!atKeyword.content.length) { return false; }
const 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, '');
});
}

73
node_modules/detective-less/package.json generated vendored Normal file
View File

@ -0,0 +1,73 @@
{
"_args": [
[
"detective-less@1.0.2",
"/Users/tatiana/selfdefined"
]
],
"_from": "detective-less@1.0.2",
"_id": "detective-less@1.0.2",
"_inBundle": false,
"_integrity": "sha512-Rps1xDkEEBSq3kLdsdnHZL1x2S4NGDcbrjmd4q+PykK5aJwDdP5MBgrJw1Xo+kyUHuv3JEzPqxr+Dj9ryeDRTA==",
"_location": "/detective-less",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "detective-less@1.0.2",
"name": "detective-less",
"escapedName": "detective-less",
"rawSpec": "1.0.2",
"saveSpec": null,
"fetchSpec": "1.0.2"
},
"_requiredBy": [
"/precinct"
],
"_resolved": "https://registry.npmjs.org/detective-less/-/detective-less-1.0.2.tgz",
"_spec": "1.0.2",
"_where": "/Users/tatiana/selfdefined",
"bugs": {
"url": "https://github.com/Mike-Dax/node-detective-less/issues"
},
"contributors": [
{
"name": "Joel Kemp",
"email": "joel@mrjoelkemp.com"
},
{
"name": "Michael Orenstein",
"email": "michael@whiteshadows.me"
}
],
"dependencies": {
"debug": "^4.0.0",
"gonzales-pe": "^4.2.3",
"node-source-walk": "^4.0.0"
},
"description": "Find the dependencies of a less file",
"devDependencies": {
"mocha": "^5.2.0"
},
"engines": {
"node": ">= 6.0"
},
"homepage": "https://github.com/Mike-Dax/node-detective-less",
"keywords": [
"detective",
"less",
"ast",
"dependencies"
],
"license": "MIT",
"main": "index.js",
"name": "detective-less",
"repository": {
"type": "git",
"url": "git+https://github.com/Mike-Dax/node-detective-less.git"
},
"scripts": {
"test": "mocha test/test.js"
},
"version": "1.0.2"
}