dts-jest
Version:
A preprocessor for Jest to snapshot test TypeScript declaration (.d.ts) files
58 lines (57 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.create_remap_cli_parser = void 0;
var tslib_1 = require("tslib");
var yargs = require("yargs");
var definitions_1 = require("./definitions");
var create_remap_cli_parser = function () {
var parser = yargs
.usage("Usage: ".concat(definitions_1.package_remap_bin, " [--outDir <path>] [--rename <template>] <TestFileGlob> ..."))
.demandCommand(1)
.epilogue("Documentation: ".concat(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;
};
tslib_1.__spreadArray(tslib_1.__spreadArray([], Object.keys(options), true), Object.keys(special_options), true).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);
};
exports.create_remap_cli_parser = create_remap_cli_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',
},
};
}