Files
agent/packages/usb/user-config-json-to-bin.ts
Róbert Kiss 78e27c3688 build: user-config-json-to-bin.ts runnable from other directory (#489)
* new setup

* make run able ts file from other directory

* do not build project
2017-11-04 17:26:34 +01:00

16 lines
672 B
TypeScript
Executable File

#!/usr/bin/env ts-node
///<reference path="./node_modules/@types/node/index.d.ts"/>
import { UhkBuffer, UserConfiguration } from 'uhk-common';
import * as fs from 'fs';
import * as path from 'path';
const outputFile = process.argv[2];
const inputFile = path.join(__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);