diff --git a/CLAUDE.md b/CLAUDE.md index 1c3f06e..a530002 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,6 +23,7 @@ Transcript-based shell integration test runner. Bun + TypeScript. - `src/match.ts` — wildcard-aware output matching and diff generation - `src/format.ts` — evaluates pass/fail, formats failures and summary - `src/update.ts` — rewrites `.shout` files with actual output (`--update` mode) +- `src/utils.ts` — shared utilities (`trimTrailingEmpty`, `escapeRegex`) - `src/duration.ts` — parses duration strings (`10s`, `500ms`, `1m`) - `src/cli/index.ts` — CLI entry point via `commander` - `src/index.ts` — barrel exports diff --git a/package.json b/package.json index 4d0a498..714d9e1 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,7 @@ }, "scripts": { "check": "bunx tsc --noEmit", - "cli:install": "bun cli:build && sudo cp dist/shout /usr/local/bin", "cli:link": "ln -sf $(pwd)/src/cli/index.ts ~/.bun/bin/shout", - "cli:uninstall": "sudo rm /usr/local/bin", "test": "bun test" }, "devDependencies": { diff --git a/src/duration.ts b/src/duration.ts index 95490d4..f0b332d 100644 --- a/src/duration.ts +++ b/src/duration.ts @@ -3,11 +3,12 @@ export function parseDuration(s: string): number { if (!match) throw new Error(`Invalid duration: ${s}`) const value = parseFloat(match[1]!) - const unit = match[2] as "ms" | "s" | "m" + const unit = match[2]! switch (unit) { case "ms": return value case "s": return value * 1000 case "m": return value * 60_000 + default: throw new Error(`Unknown unit: ${unit}`) } } diff --git a/src/index.ts b/src/index.ts index 107ee68..29281a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export type { Command, ShoutFile } from "./parse.ts" +export type { Command, Directive, ShoutFile } from "./parse.ts" export type { CommandResult, FileResult } from "./run.ts" export type { DiffLine } from "./match.ts" export type { TestResult } from "./format.ts" diff --git a/src/run.ts b/src/run.ts index 931b651..4e34396 100644 --- a/src/run.ts +++ b/src/run.ts @@ -3,7 +3,7 @@ import { tmpdir } from "node:os" import { join } from "node:path" import type { Command, ShoutFile } from "./parse.ts" -import { trimTrailingEmpty, escapeRegex } from "./utils.ts" +import { trimTrailingEmpty } from "./utils.ts" export type CommandResult = { command: Command @@ -46,7 +46,6 @@ function buildScript(commands: Command[]): string { function parseSentinelOutput( raw: string, - sentinel: string, commandCount: number, ): { outputs: string[][]; exitCodes: number[] } { const outputs: string[][] = [] @@ -54,7 +53,7 @@ function parseSentinelOutput( // Split by sentinel lines const sentinelRegex = new RegExp( - `${escapeRegex(sentinel)}(\\d+)_(\\d+)__`, + `${SENTINEL_PREFIX}(\\d+)_(\\d+)__`, ) let remaining = raw @@ -146,7 +145,6 @@ export async function runFile( const { outputs, exitCodes } = parseSentinelOutput( stdout, - SENTINEL_PREFIX, file.commands.length, )