Skip to content

Commit b153991

Browse files
authoredJul 9, 2024
Add jest test dev bin (#124)
Signed-off-by: Derek Anderson <dmikey@users.noreply.github.com>
1 parent 0735751 commit b153991

File tree

7 files changed

+11642
-5457
lines changed

7 files changed

+11642
-5457
lines changed
 

‎.vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Build",
11+
"skipFiles": ["<node_internals>/**"],
12+
"program": "${workspaceFolder}/dev-bin.js",
13+
"outFiles": ["${workspaceFolder}/**/*.js"],
14+
"args": ["sites", "build", "/Projects/example-apps/react-blog-app"]
15+
}
16+
]
17+
}

‎dev-bin.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
#!/usr/bin/env node
22
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";
55

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);
1111
} 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+
}
1626
}

‎jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/tests/**/*.test.ts"],
5+
};

0 commit comments

Comments
 (0)
Please sign in to comment.