/* M02 일위대가 수량 · 반영 · 합(`M02_MasterTemplete_Labor_Calc.ts` `settle`) 거울 헬퍼 — * 그 자리에서 트랜스파일해 Node 로 돌림(상대 경로 .ts 가져옴도 · B09 `rounddown` 751-3) · * stdin = {답, 문서, 값, 열?} · stdout = settle 결과 JSON · {밑: {기준, 줄}} = `rateBase`(778-4). */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const file = path.join( __dirname, "..", "..", "M02_MasterTemplete", "M02_MasterTemplete_Labor_Calc.ts", ); function load(at) { const js = ts.transpileModule(fs.readFileSync(at, "utf8"), { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, }).outputText; const box = { exports: {} }; const need = (p) => p.startsWith(".") ? load(path.resolve(path.dirname(at), `${p}.ts`)) : require(p); new Function("exports", "module", "require", js)(box.exports, box, need); return box.exports; } const box = { exports: load(file) }; const input = JSON.parse(fs.readFileSync(0, "utf8")); const out = input.밑 ? box.exports.rateBase(input.밑.기준, input.밑.줄) : box.exports.settle(input.답, input.문서, input.값, input.열); process.stdout.write(JSON.stringify(out));