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

8
node_modules/detective-es6/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,8 @@
language: node_js
node_js:
- "10"
- "8"
- "6"
notifications:
email: false

23
node_modules/detective-es6/Readme.md generated vendored Normal file
View File

@@ -0,0 +1,23 @@
### detective-es6 [![npm](http://img.shields.io/npm/v/detective-es6.svg)](https://npmjs.org/package/detective-es6) [![npm](http://img.shields.io/npm/dm/detective-es6.svg)](https://npmjs.org/package/detective-es6)
> Get the dependencies of an ES6 module
`npm install detective-es6`
### Usage
```js
var detective = require('detective-es6');
var mySourceCode = fs.readFileSync('myfile.js', 'utf8');
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
```
* Supports JSX, Flow, and any other features that [node-source-walk](https://github.com/mrjoelkemp/node-source-walk) supports.
#### License
MIT

49
node_modules/detective-es6/index.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
'use strict';
var Walker = require('node-source-walk');
/**
* Extracts the dependencies of the supplied es6 module
*
* @param {String|Object} src - File's content or AST
* @param {Object} options - optional extra settings
* @return {String[]}
*/
module.exports = function(src, options) {
const walker = new Walker();
const dependencies = [];
if (typeof src === 'undefined') { throw new Error('src not given'); }
if (src === '') {
return dependencies;
}
walker.walk(src, function(node) {
switch (node.type) {
case 'ImportDeclaration':
if (options && options.skipTypeImports && node.importKind == 'type') {
break;
}
if (node.source && node.source.value) {
dependencies.push(node.source.value);
}
break;
case 'ExportNamedDeclaration':
case 'ExportAllDeclaration':
if (node.source && node.source.value) {
dependencies.push(node.source.value);
}
break;
case 'CallExpression':
if (node.callee.type === 'Import' && node.arguments.length) {
dependencies.push(node.arguments[0].value);
}
default:
return;
}
});
return dependencies;
};

69
node_modules/detective-es6/package.json generated vendored Normal file
View File

@@ -0,0 +1,69 @@
{
"_args": [
[
"detective-es6@2.1.0",
"/Users/tatiana/selfdefined"
]
],
"_from": "detective-es6@2.1.0",
"_id": "detective-es6@2.1.0",
"_inBundle": false,
"_integrity": "sha512-QSHqKGOp/YBIfmIqKXaXeq2rlL+bp3bcIQMfZ+0PvKzRlELSOSZxKRvpxVcxlLuocQv4QnOfuWGniGrmPbz8MQ==",
"_location": "/detective-es6",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "detective-es6@2.1.0",
"name": "detective-es6",
"escapedName": "detective-es6",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/precinct"
],
"_resolved": "https://registry.npmjs.org/detective-es6/-/detective-es6-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Joel Kemp",
"email": "joel@mrjoelkemp.com"
},
"bugs": {
"url": "https://github.com/mrjoelkemp/node-detective-es6/issues"
},
"dependencies": {
"node-source-walk": "^4.0.0"
},
"description": "Get the dependencies of an es6 module",
"devDependencies": {
"jscs": "~2.4.0",
"mocha": "^5.2.0"
},
"engines": {
"node": ">= 6.0"
},
"homepage": "https://github.com/mrjoelkemp/node-detective-es6",
"keywords": [
"detective",
"es6",
"es2015",
"dependencies",
"module",
"ast",
"import"
],
"license": "MIT",
"main": "index.js",
"name": "detective-es6",
"repository": {
"type": "git",
"url": "git+https://github.com/mrjoelkemp/node-detective-es6.git"
},
"scripts": {
"test": "jscs -p google index.js test && mocha test/test.js"
},
"version": "2.1.0"
}

107
node_modules/detective-es6/test/test.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
'use strict';
const assert = require('assert');
const detective = require('../');
describe('detective-es6', function() {
const ast = {
type: 'Program',
body: [{
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'x'
},
init: {
type: 'Literal',
value: 4,
raw: '4'
}
}],
kind: 'let'
}]
};
it('accepts an ast', function() {
const deps = detective(ast);
assert(!deps.length);
});
it('retrieves the dependencies of es6 modules', function() {
const deps = detective('import {foo, bar} from "mylib";');
assert(deps.length === 1);
assert(deps[0] === 'mylib');
});
it('retrieves the re-export dependencies of es6 modules', function() {
const deps = detective('export {foo, bar} from "mylib";');
assert(deps.length === 1);
assert(deps[0] === 'mylib');
});
it('retrieves the re-export * dependencies of es6 modules', function() {
const deps = detective('export * from "mylib";');
assert(deps.length === 1);
assert(deps[0] === 'mylib');
});
it('handles multiple imports', function() {
const deps = detective('import {foo, bar} from "mylib";\nimport "mylib2"');
assert(deps.length === 2);
assert(deps[0] === 'mylib');
assert(deps[1] === 'mylib2');
});
it('handles default imports', function() {
const deps = detective('import foo from "foo";');
assert(deps.length === 1);
assert(deps[0] === 'foo');
});
it('handles dynamic imports', function() {
const deps = detective('import("foo").then(foo => foo());');
assert(deps.length === 1);
assert(deps[0] === 'foo');
})
it('returns an empty list for non-es6 modules', function() {
const deps = detective('var foo = require("foo");');
assert(!deps.length);
});
it('returns an empty list for empty files', function() {
const deps = detective('');
assert.equal(deps.length, 0);
});
it('throws when content is not provided', function() {
assert.throws(function() {
detective();
}, Error, 'src not given');
});
it('does not throw with jsx in a module', function() {
assert.doesNotThrow(function() {
detective('import foo from \'foo\'; var templ = <jsx />;');
});
});
it('does not throw on an async ES7 function', function() {
assert.doesNotThrow(function() {
detective('import foo from \'foo\'; export default async function foo() {}');
});
});
it('respects settings for type imports', function() {
const source = 'import type {foo} from "mylib";';
const depsWithTypes = detective(source);
const depsWithoutTypes = detective(source, {skipTypeImports: true});
assert.deepEqual(depsWithTypes, ['mylib']);
assert.deepEqual(depsWithoutTypes, []);
});
});