Utilize ts-node to run user-config-json-to-bin.ts. Remove the lint pre-commit hook because I couldn't commit with git.

This commit is contained in:
László Monda
2017-11-03 00:33:37 +01:00
parent ea700852bc
commit 2ae7abe440
4 changed files with 86 additions and 959 deletions

1020
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -50,8 +50,7 @@
"webpack": "2.4.1" "webpack": "2.4.1"
}, },
"pre-commit": [ "pre-commit": [
"precommit-msg", "precommit-msg"
"lint"
], ],
"scripts": { "scripts": {
"postinstall": "lerna bootstrap", "postinstall": "lerna bootstrap",

View File

@@ -1,18 +1,11 @@
{ {
"name": "agent-usb", "name": "agent-usb",
"version": "1.0.0", "version": "1.0.0",
"description": "Agent preliminary USB code", "description": "Agent USB scripts",
"main": "UhkConnection.js", "main": "uhk.js",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": {
"build": "npm run tsc && npm run chmod",
"tsc": "tsc",
"chmod": "shx chmod u+x dist/*.js",
"watch": "tsc -w"
},
"devDependencies": { "devDependencies": {
"@types/node": "8.0.28", "@types/node": "8.0.28",
"shx": "0.2.2",
"typescript": "2.5.3" "typescript": "2.5.3"
}, },
"dependencies": { "dependencies": {

11
packages/usb/user-config-json-to-bin.ts Normal file → Executable file
View File

@@ -1,15 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env ts-node
import { UhkBuffer, UserConfiguration } from 'uhk-common'; import { UhkBuffer, UserConfiguration } from 'uhk-common';
import * as fs from 'fs'; import * as fs from 'fs';
const inputFile = process.argv[2]; const outputFile = process.argv[2];
console.log(inputFile); const inputFile = `${__dirname}/../uhk-web/src/app/services/user-config.json`;
const outputFile = process.argv[3];
const config1Js = JSON.parse(fs.readFileSync(inputFile).toString()); const config1Js = JSON.parse(fs.readFileSync(inputFile).toString());
const config1Ts: UserConfiguration = new UserConfiguration().fromJsonObject(config1Js); const config1Ts: UserConfiguration = new UserConfiguration().fromJsonObject(config1Js);
const config1Buffer = new UhkBuffer(); const config1Buffer = new UhkBuffer();
config1Ts.toBinary(config1Buffer); config1Ts.toBinary(config1Buffer);
const config1BufferContent = config1Buffer.getBufferContent(); const config1BufferContent = config1Buffer.getBufferContent();
fs.writeFileSync('user-config.bin', config1BufferContent); fs.writeFileSync(outputFile, config1BufferContent);