-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
37 lines (34 loc) · 935 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
const path = require('path');
const Graph = require('./lib/graph');
const ImportParser = require('./lib/import-parser');
/**
* class ImportGraph
*/
class ImportGraph {
/**
* Will create a graph for a file or a directory
* @name ImportGraph.createGraph
* @param {String} entryPath
* @param {Object} [options]
* @returns {Promise<Graph, string>}
*/
createGraph(entryPath, options) {
options = processOptions(options);
let importParser = new ImportParser();
let graph = new Graph(importParser, options);
return graph.init(entryPath);
}
}
/**
* @param {Object} options
*/
function processOptions(options) {
return Object.assign({
extensions: ['js'],
dependencyPattern: 'js',
loadPaths: [process.cwd()]
}, options);
}
let importGraphInstance = new ImportGraph();
module.exports = importGraphInstance;