forked from anyproto/anytype-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
save-node-deps.js
33 lines (26 loc) · 891 Bytes
/
save-node-deps.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
'use strict';
const fs = require('fs');
const stdin = process.openStdin();
let data = '';
stdin.on('data', (chunk) => {
data +=chunk;
});
const skipIds = [ 'electron' ];
stdin.on('end', function() {
let lines = data.split('\n').sort();
const baseDepsFile = fs.readFileSync('package.deps.json');
const baseDepsJSON = JSON.parse(baseDepsFile);
const packageFile = fs.readFileSync('package.json');
const packageJSON = JSON.parse(packageFile);
lines = [ ...new Set(lines) ];
lines = lines.filter((el) => {
return el && el.match(/^node_modules/) && !el.match(new RegExp(`^node_modules/(${skipIds.join('|')})$`));
}).map((it) => {
it = it.replace(/\\/g, '/');
return { from: it, to: it };
});
console.log(lines);
packageJSON.build.files = baseDepsJSON.concat(lines);
const jsonS = JSON.stringify(packageJSON, null, '\t');
fs.writeFileSync('package.json', jsonS);
});