UNPKG

@creditkarma/thrift-parser

Version:

A parser for Thrift written in TypeScript

21 lines 885 B
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const fs = require("fs"); const mkdir_1 = require("./mkdir"); const index_1 = require("../index"); const resolveOptions_1 = require("./resolveOptions"); const cliArgs = process.argv.slice(2); const options = resolveOptions_1.resolveOptions(cliArgs); 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 mkdir_1.mkdir(path.dirname(outFile)); // Write json to file fs.writeFileSync(outFile, json, 'utf-8'); }); //# sourceMappingURL=index.js.map