@borduhh/avro-typescript-generator
Version:
Converts AVRO schemas to Typescript types
44 lines (43 loc) • 1.41 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateOutputDir = exports.retrieveCLIArguments = void 0;
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
/**
* Retrieves CLI Arguments for use
*/
const retrieveCLIArguments = () => (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
.option('input', {
alias: 'i',
demandOption: true,
default: 'schmeas/*.avsc',
describe: 'The input patterns',
type: 'array',
})
.option('outputDir', {
alias: 'o',
demandOption: true,
default: 'types/',
describe: 'The directory to where the typescript output should be located',
type: 'string',
})
.option('configFile', {
alias: 'c',
demandOption: true,
default: 'avro-typescript.config.json',
describe: 'The path to your config file.',
type: 'string',
})
.help()
.parseSync();
exports.retrieveCLIArguments = retrieveCLIArguments;
/**
* Validates output directory path and removes the trailing slash
* @param path The path to validate
* @returns The validated path
*/
const validateOutputDir = (path) => path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
exports.validateOutputDir = validateOutputDir;