Files
agent/packages/usb/user-config-json-to-bin.ts
Róbert Kiss ac76674469 chore: add convert-user-config-to-bin npm script (#1022)
usage of the script
`$ npm run convert-user-config-to-bin -- <path of the bin file>`
2019-08-23 19:33:14 +02:00

12 lines
547 B
TypeScript
Executable File

import { UhkBuffer, UserConfiguration } from 'uhk-common';
import * as fs from 'fs';
const outputFile = process.argv[2];
const inputFile = `${__dirname}/../uhk-web/src/app/services/user-config.json`;
const config1Js = JSON.parse(fs.readFileSync(inputFile).toString());
const config1Ts: UserConfiguration = new UserConfiguration().fromJsonObject(config1Js);
const config1Buffer = new UhkBuffer();
config1Ts.toBinary(config1Buffer);
const config1BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync(outputFile, config1BufferContent);