(cli)
| 79 | * @returns {void} |
| 80 | */ |
| 81 | const runCli = (cli) => { |
| 82 | const path = require("path"); |
| 83 | |
| 84 | const pkgPath = require.resolve(`${cli.package}/package.json`); |
| 85 | |
| 86 | /** @type {Record<string, EXPECTED_ANY> & { type: string, bin: Record<string, string> }} */ |
| 87 | const pkg = require(pkgPath); |
| 88 | |
| 89 | if (pkg.type === "module" || /\.mjs/i.test(pkg.bin[cli.binName])) { |
| 90 | import(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])).catch( |
| 91 | (err) => { |
| 92 | console.error(err); |
| 93 | process.exitCode = 1; |
| 94 | } |
| 95 | ); |
| 96 | } else { |
| 97 | require(path.resolve(path.dirname(pkgPath), pkg.bin[cli.binName])); |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | /** |
| 102 | * @typedef {object} CliOption |
no test coverage detected