1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00
anytype-ts/save-node-deps.js
2022-09-09 08:40:50 +03:00

34 lines
No EOL
883 B
JavaScript

'use strict';
const fs = require('fs');
let stdin = process.openStdin();
let data = "";
stdin.on('data', function(chunk) {
data +=chunk;
});
let skipIds = [ 'electron' ];
stdin.on('end', function() {
let lines = data.split('\n').sort();
let baseDepsFile = fs.readFileSync('package.deps.json');
let baseDepsJSON = JSON.parse(baseDepsFile);
let packageFile = fs.readFileSync('package.json');
let 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);
let jsonS = JSON.stringify(packageJSON, null, '\t');
fs.writeFileSync('package.json', jsonS);
});