From 50d5b71d03deb7d69b0817130338f0ab157241de Mon Sep 17 00:00:00 2001 From: Bauke Date: Sat, 27 Jan 2024 13:00:48 +0100 Subject: [PATCH] Switch from npm scripts to cargo-make tasks. --- Makefile.toml | 45 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 11 +---------- tests/example.ts | 4 ++-- tests/index.html | 1 - tests/index.ts | 1 + 5 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 Makefile.toml diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..b3a4a1b --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,45 @@ +# Build the package. +[tasks.build] +clear = true +dependencies = ["clean", "lint", "test", "build-types", "build-js"] + +# Build the JavaScript. +[tasks.build-js] +clear = true +command = "pnpm" +args = ["tsx", "esbuild.ts"] + +# Build the TypeScript type declarations. +[tasks.build-types] +clear = true +command = "pnpm" +args = ["tsc"] + +# Clean the build directory. +[tasks.clean] +clear = true +command = "pnpm" +args = ["trash", "build/"] + +# Run the full set of linting and testing. +[tasks.lint] +clear = true +dependencies = ["lint-js", "test"] + +# Lint the TypeScript using XO. +[tasks.lint-js] +clear = true +command = "pnpm" +args = ["xo"] + +# Run the tests. +[tasks.test] +clear = true +command = "pnpm" +args = ["tsx", "tests/index.ts"] + +# Start a live-reloading server that watches for changes. +[tasks.watch] +clear = true +command = "pnpm" +args = ["vite"] diff --git a/package.json b/package.json index cbddbfc..3d07392 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,6 @@ "license": "AGPL-3.0-or-later", "version": "0.2.1", "homepage": "https://git.bauke.xyz/Holllo/test", - "bugs": { - "email": "helllo@holllo.org", - "url": "https://github.com/Holllo/test/issues" - }, "publishConfig": { "access": "public" }, @@ -17,16 +13,11 @@ "files": [ "build/" ], - "scripts": { - "build": "tsx esbuild.ts && tsc", - "dev": "vite", - "lint": "xo", - "test": "pnpm run build && tsx tests/index.ts && tsx tests/example.ts" - }, "devDependencies": { "@bauke/eslint-config": "^0.1.2", "@bauke/prettier-config": "^0.1.2", "esbuild": "^0.16.10", + "trash-cli": "^5.0.0", "tsx": "^3.12.1", "typescript": "^4.9.4", "vite": "^4.0.2", diff --git a/tests/example.ts b/tests/example.ts index 9337d8e..d0e7845 100644 --- a/tests/example.ts +++ b/tests/example.ts @@ -1,8 +1,8 @@ -import {setup} from "../build/index.js"; +import {setup} from "../source/index.js"; const add = (a: number, b: number): number => a + b; -void setup("add", async (group) => { +void setup("Example add", async (group) => { group.test("1 + 1", async (test) => { test.equals(add(1, 1), 2); }); diff --git a/tests/index.html b/tests/index.html index 9a436ab..f655f50 100644 --- a/tests/index.html +++ b/tests/index.html @@ -16,7 +16,6 @@ - diff --git a/tests/index.ts b/tests/index.ts index 526cb64..7ff822a 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -1,6 +1,7 @@ import {setup} from "../source/index.js"; await import("./assertions.js"); +await import("./example.js"); async function add(a: number, b: number): Promise { await new Promise((resolve) => {