feat: make road compiler standalone
This commit is contained in:
16
bin/road-compiler.js
Executable file
16
bin/road-compiler.js
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { compiler } = require("../src");
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const index = args.indexOf("--input");
|
||||
if (index < 0 || !args[index + 1] || index + 2 !== args.length) {
|
||||
throw new Error("Usage: road-compiler --input <RoadCompilerInput.json>");
|
||||
}
|
||||
const inputFile = path.resolve(args[index + 1]);
|
||||
const input = JSON.parse(fs.readFileSync(inputFile, "utf8"));
|
||||
const { result, comparison } = compiler.compileInput(input);
|
||||
console.log(`NATIVE_ROAD_COMPILE_DONE ${JSON.stringify({ areaId: input.areaId, roads: result.model.roads.length, endpoints: result.model.endpoints.length, diagnostics: result.diagnostics.length, output: input.outDir, comparison })}`);
|
||||
Reference in New Issue
Block a user