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

26
node_modules/detective-cjs/Readme.md generated vendored Normal file
View File

@ -0,0 +1,26 @@
#### detective-cjs [![npm](http://img.shields.io/npm/v/detective-cjs.svg)](https://npmjs.org/package/detective-cjs) [![npm](http://img.shields.io/npm/dm/detective-cjs.svg)](https://npmjs.org/package/detective-cjs)
> Get the dependencies of an CommonJS module
`npm install detective-cjs`
But dude, substack already built this: node-detective. Yes, but I needed the capability to reuse an AST
and this was unlikely to be merged timely. I can also support jsx and other syntactic constructs faster.
### Usage
```js
var detective = require('detective-cjs');
var mySourceCode = fs.readFileSync('myfile.js', 'utf8');
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
```
* Supports JSX, ES7, and any other features that [node-source-walk](https://github.com/mrjoelkemp/node-source-walk) supports.
#### License
MIT

46
node_modules/detective-cjs/index.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
'use strict';
const Walker = require('node-source-walk');
const types = require('ast-module-types');
/**
* @param {String|Object} content - A file's string content or its AST
* @return {String[]} The file's dependencies
*/
module.exports = function(content) {
const walker = new Walker();
const dependencies = [];
walker.walk(content, function(node) {
if (!types.isRequire(node) ||
!node.arguments ||
!node.arguments.length) {
return;
}
if (types.isPlainRequire(node)) {
const result = extractDependencyFromRequire(node);
if (result) {
dependencies.push(result);
}
} else if (types.isMainScopedRequire(node)) {
dependencies.push(extractDependencyFromMainRequire(node));
}
});
return dependencies;
};
function extractDependencyFromRequire(node) {
if (node.arguments[0].type === 'Literal' || node.arguments[0].type === 'StringLiteral') {
return node.arguments[0].value;
} else if (node.arguments[0].type === 'TemplateLiteral') {
return node.arguments[0].quasis[0].value.raw;
}
}
function extractDependencyFromMainRequire(node) {
return node.arguments[0].value;
}

72
node_modules/detective-cjs/package.json generated vendored Normal file
View File

@ -0,0 +1,72 @@
{
"_args": [
[
"detective-cjs@3.1.1",
"/Users/tatiana/selfdefined"
]
],
"_from": "detective-cjs@3.1.1",
"_id": "detective-cjs@3.1.1",
"_inBundle": false,
"_integrity": "sha512-JQtNTBgFY6h8uT6pgph5QpV3IyxDv+z3qPk/FZRDT9TlFfm5dnRtpH39WtQEr1khqsUxVqXzKjZHpdoQvQbllg==",
"_location": "/detective-cjs",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "detective-cjs@3.1.1",
"name": "detective-cjs",
"escapedName": "detective-cjs",
"rawSpec": "3.1.1",
"saveSpec": null,
"fetchSpec": "3.1.1"
},
"_requiredBy": [
"/precinct"
],
"_resolved": "https://registry.npmjs.org/detective-cjs/-/detective-cjs-3.1.1.tgz",
"_spec": "3.1.1",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Joel Kemp",
"email": "joel@mrjoelkemp.com"
},
"bugs": {
"url": "https://github.com/mrjoelkemp/node-detective-cjs/issues"
},
"dependencies": {
"ast-module-types": "^2.4.0",
"node-source-walk": "^4.0.0"
},
"description": "Get the dependencies of a CommonJS module by traversing its AST",
"devDependencies": {
"jscs": "^3.0.7",
"jscs-preset-mrjoelkemp": "~2.0.0",
"mocha": "^5.2.0",
"sinon": "^6.1.5"
},
"engines": {
"node": ">= 6.0"
},
"homepage": "https://github.com/mrjoelkemp/node-detective-cjs",
"keywords": [
"detective",
"commonjs",
"dependencies",
"ast",
"static analysis",
"cjs",
"jsx"
],
"license": "MIT",
"main": "index.js",
"name": "detective-cjs",
"repository": {
"type": "git",
"url": "git+https://github.com/mrjoelkemp/node-detective-cjs.git"
},
"scripts": {
"test": "jscs index.js test && mocha test/test.js"
},
"version": "3.1.1"
}