UNPKG

@creditkarma/thrift-parser

Version:

A parser for Thrift written in TypeScript

21 lines 900 B
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); const path = require("path"); const index_1 = require("../index"); const mkdir_1 = require("./mkdir"); const resolveOptions_1 = require("./resolveOptions"); const cliArgs = process.argv.slice(2); const options = (0, resolveOptions_1.resolveOptions)(cliArgs); (0, index_1.parseFiles)(options).forEach((ast, index) => { const json = JSON.stringify(ast, null, 2); const file = options.files[index]; const outDir = path.resolve(process.cwd(), options.rootDir, options.outDir); const outFile = path.resolve(outDir, file.replace('.thrift', '.json')); // Verify output directory exists, create if it doesn't (0, mkdir_1.mkdir)(path.dirname(outFile)); // Write json to file fs.writeFileSync(outFile, json, 'utf-8'); }); //# sourceMappingURL=index.js.map