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-08-03 10:42:38 +03:00

25 lines
No EOL
723 B
JavaScript

'use strict';
const fs = require('fs');
let stdin = process.openStdin();
let data = "";
stdin.on('data', function(chunk) {
data +=chunk;
});
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/); }).map((it) => { return { from: it, to: it }; });
packageJSON.build.files = baseDepsJSON.concat(lines);
let jsonS = JSON.stringify(packageJSON, null, '\t');
fs.writeFileSync('package.json', jsonS);
});