Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 1x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x | #!/usr/bin/env node
import { realpathSync } from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import 'dotenv/config'
import { createCli } from './cli/commands/index.ts'
const currentFile = realpathSync(fileURLToPath(import.meta.url))
function resolveInvokedPath(invoked?: string): string | null {
if (invoked == null) return null
try {
return realpathSync(invoked)
} catch {
return path.resolve(invoked)
}
}
export function shouldRunCli(invoked?: string): boolean {
const resolved = resolveInvokedPath(invoked)
if (resolved == null) return false
return resolved === currentFile
}
export async function main(args = process.argv.slice(2)): Promise<void> {
const cli = createCli()
const exitCode = await cli.run(args)
if (exitCode !== 0) {
process.exitCode = exitCode
}
}
export function runCliWhenExecuted(): void {
if (!shouldRunCli(process.argv[1])) return
void main().catch((error) => {
console.error((error as Error).message)
process.exitCode = 1
})
}
runCliWhenExecuted()
|