Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jest test dev bin #124

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Build",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/dev-bin.js",
"outFiles": ["${workspaceFolder}/**/*.js"],
"args": ["sites", "build", "/Projects/example-apps/react-blog-app"]
}
]
}
32 changes: 21 additions & 11 deletions dev-bin.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#!/usr/bin/env node
require("ts-node/register");
const compareVersions = require("compare-versions")
const MIN_NODE_VERSION = '14.17.6'
const compareVersions = require("compare-versions");
const MIN_NODE_VERSION = "14.17.6";

if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, '<')) {
console.error(
`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.`
)
process.exit(1)
if (compareVersions.compare(process.versions.node, MIN_NODE_VERSION, "<")) {
console.error(
`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.`,
);
process.exit(1);
} else {
const { main } = require("./src/index");
const { version } = require("./package.json");

main(process.argv.slice(2), { version });
const { main } = require("./src/index");
const { version } = require("./package.json");

const runCLI = (args) => {
main(args, { version });
};

// Export the runCLI function for testing
module.exports = { runCLI };

// Run the CLI if executed directly
if (require.main === module) {
runCLI(process.argv.slice(2));
}
}
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/tests/**/*.test.ts"],
};
Loading
Loading