-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeModulesCompare.ts
More file actions
84 lines (76 loc) · 1.96 KB
/
Copy pathnodeModulesCompare.ts
File metadata and controls
84 lines (76 loc) · 1.96 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env node
import meow from 'meow';
import { getPackage } from '../lib/getPackage.js';
import { nodeModulesCompare } from '../nodeModulesCompare.js';
const packageContent = await getPackage();
const packageContentParsed = JSON.parse(packageContent);
const cli = meow({
importMeta: import.meta,
flags: {
h: {
type: 'boolean',
},
inputFile: {
type: 'string',
},
inputFileWithChanges: {
type: 'string',
},
outputDirectory: {
type: 'string',
},
shouldOmitNodeModuleData: {
type: 'boolean',
},
},
});
const {
h,
inputFile,
inputFileWithChanges,
outputDirectory,
shouldOmitNodeModuleData,
} = cli.flags;
const runNodeModulesCompare = async () => {
console.log(
`running ${packageContentParsed.name}@${packageContentParsed.version} ✨`,
);
const result = await nodeModulesCompare({
inputFile,
inputFileWithChanges,
outputDirectory,
shouldOmitNodeModuleData,
});
if (result.resultFilePath) {
console.log(` - result path:`, result.resultFilePath);
}
if (result.nodeModules) {
console.log(
` - module files analyzed:`,
Object.keys(result.nodeModules).length,
);
}
if (result.nodeModulesWithChanges) {
console.log(
` - newer module files analyzed:`,
Object.keys(result.nodeModulesWithChanges).length,
);
}
if (result.diff) {
console.log(` - a diff was found between builds:`);
console.log(` - total bytes diff:`, result.diff.totalBytes);
console.log(` - added:`, result.diff.added.length);
console.log(` - changed:`, result.diff.changed.length);
console.log(` - removed:`, result.diff.removed.length);
} else if (result.nodeModulesWithChanges) {
console.log(` - no diff was found`);
}
};
if (h) {
console.log(
`Please refer to GitHub for options:\n` +
` https://github.com/foo-software/node-modules-compare/tree/main#usage-options`,
);
} else {
runNodeModulesCompare();
}