diff --git a/README.md b/README.md index d0ade87..e6e2955 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ examples in `tests/examples/`. Useful commands are: ```bash npm run build # Compile the package npm run test:all # Build and run all tests -npm run test:example # Run example (requires recursive submodules) +npm run test:example # Run example (example.ts requires recursive submodules) ``` The repository uses a recursive WARDuino/WABT test fixture for hardware and diff --git a/assets/demo.gif b/assets/demo.gif index 390a18c..393b50b 100644 Binary files a/assets/demo.gif and b/assets/demo.gif differ diff --git a/bin/latch.js b/bin/latch.js new file mode 100755 index 0000000..f3e79fb --- /dev/null +++ b/bin/latch.js @@ -0,0 +1,15 @@ +#!/usr/bin/env node + +const {resolve} = require('node:path'); + +const [testFile, ...testArguments] = process.argv.slice(2); + +if (!testFile || testFile === '--help' || testFile === '-h') { + const output = testFile ? console.log : console.error; + output('Usage: latch [arguments]'); + process.exitCode = testFile ? 0 : 1; +} else { + process.argv = [process.argv[0], resolve(testFile), ...testArguments]; + require('ts-node/register/transpile-only'); + require(process.argv[1]); +} diff --git a/package-lock.json b/package-lock.json index 7785d34..49c9312 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,11 @@ "react": "^17.0.2", "source-map": "^0.7.6", "ts-node": "^10.9.2", - "tslib": "^2.8.1" + "tslib": "^2.8.1", + "typescript": "^6.0.3" + }, + "bin": { + "latch": "bin/latch.js" }, "devDependencies": { "@ava/typescript": "^7.0.0", @@ -36,7 +40,6 @@ "ink-testing-library": "^2.1.0", "mqtt": "^5.15.1", "serialport": "^13.0.0", - "typescript": "^6.0.3", "typescript-eslint": "^8.60.1" } }, diff --git a/package.json b/package.json index 46d746a..0dab90d 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,9 @@ }, "main": "dist/index.js", "types": "dist/types/index.d.ts", + "bin": { + "latch": "./bin/latch.js" + }, "files": [ "dist", "bin" @@ -49,7 +52,8 @@ "react": "^17.0.2", "source-map": "^0.7.6", "ts-node": "^10.9.2", - "tslib": "^2.8.1" + "tslib": "^2.8.1", + "typescript": "^6.0.3" }, "devDependencies": { "@ava/typescript": "^7.0.0", @@ -70,7 +74,6 @@ "ink-testing-library": "^2.1.0", "mqtt": "^5.15.1", "serialport": "^13.0.0", - "typescript": "^6.0.3", "typescript-eslint": "^8.60.1" }, "ava": {