UNPKG

git-cat-file

Version:

Pure JavaScript `git cat-file -p` for node.js

28 lines (27 loc) 782 B
"use strict"; /** * https://github.com/kawanet/git-cat-file */ Object.defineProperty(exports, "__esModule", { value: true }); exports.parseOptions = void 0; function parseOptions(input) { const argv = require("process.argv")(input.args)({}); const args = argv["--"] || []; const shortDef = input.short; const shortParams = {}; while (/^-/.test(args[0])) { const key = args.shift().slice(1); if (!(key in shortDef)) { shortParams.h = true; break; } if ("string" === typeof shortDef[key]) { shortParams[key] = args.shift(); } else { shortParams[key] = true; } } return { long: argv, short: shortParams, args }; } exports.parseOptions = parseOptions;