UNPKG

dts-jest

Version:

A preprocessor for Jest to snapshot test TypeScript declaration (.d.ts) files

55 lines (54 loc) 1.87 kB
"use strict"; exports.__esModule = true; var yargs = require("yargs"); var definitions_1 = require("./definitions"); exports.create_remap_cli_parser = function () { var parser = yargs .usage("Usage: " + definitions_1.package_remap_bin + " [--outDir <path>] [--rename <template>] <TestFileGlob> ...") .demandCommand(1) .epilogue("Documentation: " + definitions_1.package_homepage); var options = get_cli_options(); var special_options = { help: { alias: 'h' }, version: { alias: 'v' } }; var is_special_key = function (key) { return key in special_options; }; Object.keys(options).concat(Object.keys(special_options)).sort() .forEach(function (key) { parser = is_special_key(key) ? parser[key]().alias(key, special_options[key].alias) : parser.option(key, options[key]); }); return parser.parse.bind(parser); }; function get_cli_options() { return { check: { alias: 'c', type: 'boolean', description: 'Throw error if target content is different from output content' }, listDifferent: { alias: 'l', type: 'boolean', description: 'Print the filenames of files that their target content is different from output content' }, outDir: { alias: 'o', type: 'string', description: 'Redirect output structure to the directory' }, rename: { alias: 'r', type: 'string', description: 'Rename output filename using template {{variable}}, available variable: filename, basename, extname' }, typescript: { alias: 't', type: 'string', description: 'Specify which TypeScript source to use' } }; }