UNPKG

@creditkarma/thrift-parser

Version:

A parser for Thrift written in TypeScript

58 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveOptions = void 0; const fs_1 = require("fs"); /** * --rootDir * --fastFail */ function resolveOptions(args) { const len = args.length; let index = 0; const options = { fastFail: false, rootDir: '.', outDir: 'thrift-json', files: [], organize: true, }; while (index < len) { const next = args[index]; switch (next) { case '--rootDir': options.rootDir = args[index + 1]; try { if ((0, fs_1.lstatSync)(options.rootDir).isDirectory()) { index += 2; break; } else { throw new Error(`Provided root directory "${options.rootDir}" isn't a directory`); } } catch (e) { throw new Error(`Provided root directory "${options.rootDir}" doesn't exist`); } case '--outDir': options.outDir = args[index + 1]; index += 2; break; case '--fastFail': options.fastFail = args[index + 1] === 'true'; index += 2; break; default: if (next.startsWith('--')) { throw new Error(`Unknown option provided to generator "${next}"`); } else { // Assume option is a file to parse options.files.push(next); index += 1; } } } return options; } exports.resolveOptions = resolveOptions; //# sourceMappingURL=resolveOptions.js.map