forked from mgechev/codelyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ts
More file actions
28 lines (25 loc) · 658 Bytes
/
package.ts
File metadata and controls
28 lines (25 loc) · 658 Bytes
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
process.stdin.setEncoding('utf8');
const blacklist = ['scripts', 'devDependencies'];
process.stdin.resume();
process.stdin.setEncoding('utf8');
let packageJson = '';
process.stdin.on('data', (chunk: string) => {
packageJson += chunk;
});
process.stdin.on('end', () => {
let parsed: any;
try {
parsed = JSON.parse(packageJson);
} catch (e) {
console.error('Cannot parse to JSON');
process.exit(1);
}
const result = {};
Object.keys(parsed).forEach((key: string) => {
if (blacklist.indexOf(key) < 0) {
result[key] = parsed[key];
}
});
process.stdout.write(JSON.stringify(result, null, 2));
packageJson = '';
});