| |
| |
|
|
| const fs = require('fs'); |
| const path = require('path'); |
|
|
| const REGISTRY_PATH = path.join(__dirname, 'mur.json'); |
|
|
| |
| function ensureRegistry() { |
| if (!fs.existsSync(REGISTRY_PATH)) { |
| fs.writeFileSync(REGISTRY_PATH, JSON.stringify({ registryVersion: "v0.1", units: [] }, null, 2)); |
| } |
| } |
|
|
| |
| function registerMU(mu) { |
| ensureRegistry(); |
|
|
| const registry = JSON.parse(fs.readFileSync(REGISTRY_PATH, 'utf8')); |
|
|
| |
| registry.units.push({ |
| id: mu.id, |
| compiledAt: mu.compiledAt, |
| length: mu.payload.length, |
| type: mu.payload.type |
| }); |
|
|
| fs.writeFileSync(REGISTRY_PATH, JSON.stringify(registry, null, 2)); |
|
|
| return registry; |
| } |
|
|
| module.exports = { registerMU }; |
|
|