-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (32 loc) · 1.08 KB
/
index.js
File metadata and controls
44 lines (32 loc) · 1.08 KB
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
38
39
40
41
42
43
'use strict';
const process = require('process');
const fs = require('fs');
var {argv} = process;
argv[2] = argv[2] || 'index.js';
const mainPath = `${argv[2]}`;
const scanner = require('./lib/scanner');
const utils = require('./lib/utils');
const moduleTypePath = 'node_modules';
const currentInfo = JSON.parse(fs.readFile(`${mainPath}/package.json`).toString());
function runModule(dirPath, origin) {
var deps = scanner.scanModuleDeps(dirPath);
var nativeDeps = scanner.scanNativeDeps(dirPath);
if (!deps) {
return;
}
utils.setDepInfo(origin, deps.packageDeps, deps.packageVersion, 'module');
utils.setDepInfo(origin, nativeDeps, deps.packageVersion);
for (let m in deps.packageDeps) {
var path = scanner.findDepsRise(`${dirPath}/${moduleTypePath}/${m}`, m);
runModule(path, origin['moduleDeps'][m]);
}
}
runModule(mainPath, utils.getRoot());
switch (argv[3]) {
case '_all':
console.log(utils.getRoot());
break;
case '_native':
console.log(require('./lib/total').allNativeMoules());
break;
}