|
1 | 1 | #!/usr/bin/env node
|
2 | 2 | require("ts-node/register");
|
3 |
| -const compareVersions = require("compare-versions") |
4 |
| -const MIN_NODE_VERSION = '14.17.6' |
| 3 | +const compareVersions = require("compare-versions"); |
| 4 | +const MIN_NODE_VERSION = "14.17.6"; |
5 | 5 |
|
6 |
| -if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, '<')) { |
7 |
| - console.error( |
8 |
| - `Bls CLI requires at least node.js v${MIN_NODE_VERSION}.\nYou are using v${process.versions.node}. Please update your version of node.js. Consider using Node.js version manager https://github.com/nvm-sh/nvm.` |
9 |
| - ) |
10 |
| - process.exit(1) |
| 6 | +if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, "<")) { |
| 7 | + console.error( |
| 8 | + `Bls CLI requires at least node.js v${MIN_NODE_VERSION}.\nYou are using v${process.versions.node}. Please update your version of node.js. Consider using Node.js version manager https://github.com/nvm-sh/nvm.`, |
| 9 | + ); |
| 10 | + process.exit(1); |
11 | 11 | } else {
|
12 |
| - const { main } = require("./src/index"); |
13 |
| - const { version } = require("./package.json"); |
14 |
| - |
15 |
| - main(process.argv.slice(2), { version }); |
| 12 | + const { main } = require("./src/index"); |
| 13 | + const { version } = require("./package.json"); |
| 14 | + |
| 15 | + const runCLI = (args) => { |
| 16 | + main(args, { version }); |
| 17 | + }; |
| 18 | + |
| 19 | + // Export the runCLI function for testing |
| 20 | + module.exports = { runCLI }; |
| 21 | + |
| 22 | + // Run the CLI if executed directly |
| 23 | + if (require.main === module) { |
| 24 | + runCLI(process.argv.slice(2)); |
| 25 | + } |
16 | 26 | }
|
0 commit comments