| ... | @@ -4,12 +4,12 @@ import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ... | @@ -4,12 +4,12 @@ import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; |
| 4 | import * as NodeServices from "@effect/platform-node/NodeServices"; | 4 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 5 | import { isCommandAvailable, resolveSpawnCommand } from "@t3tools/shared/shell"; | 5 | import { isCommandAvailable, resolveSpawnCommand } from "@t3tools/shared/shell"; |
| 6 | import * as Console from "effect/Console"; | 6 | import * as Console from "effect/Console"; |
| 7 | import * as Data from "effect/Data"; | | |
| 8 | import * as Effect from "effect/Effect"; | 7 | import * as Effect from "effect/Effect"; |
| 9 | import * as FileSystem from "effect/FileSystem"; | 8 | import * as FileSystem from "effect/FileSystem"; |
| 10 | import * as Logger from "effect/Logger"; | 9 | import * as Logger from "effect/Logger"; |
| 11 | import * as Path from "effect/Path"; | 10 | import * as Path from "effect/Path"; |
| 12 | import * as PlatformError from "effect/PlatformError"; | 11 | import * as PlatformError from "effect/PlatformError"; |
| | 12 | import * as Schema from "effect/Schema"; |
| 13 | import { Command } from "effect/unstable/cli"; | 13 | import { Command } from "effect/unstable/cli"; |
| 14 | import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; | 14 | import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; |
| 15 | | 15 | |
| ... | @@ -18,9 +18,19 @@ interface NativeStaticTool { | ... | @@ -18,9 +18,19 @@ interface NativeStaticTool { |
| 18 | readonly installHint: string; | 18 | readonly installHint: string; |
| 19 | } | 19 | } |
| 20 | | 20 | |
| 21 | class NativeStaticCheckError extends Data.TaggedError("NativeStaticCheckError")<{ | 21 | export class NativeStaticCheckCommandError extends Schema.TaggedErrorClass<NativeStaticCheckCommandError>()( |
| 22 | readonly message: string; | 22 | "NativeStaticCheckCommandError", |
| 23 | }> {} | 23 | { |
| | 24 | command: Schema.String, |
| | 25 | args: Schema.Array(Schema.String), |
| | 26 | cwd: Schema.String, |
| | 27 | exitCode: Schema.Int, |
| | 28 | }, |
| | 29 | ) { |
| | 30 | override get message(): string { |
| | 31 | return `Native static check command '${this.command}' exited with code ${this.exitCode}.`; |
| | 32 | } |
| | 33 | } |
| 24 | | 34 | |
| 25 | const tools = [ | 35 | const tools = [ |
| 26 | { | 36 | { |
| ... | @@ -85,8 +95,11 @@ const runCommand = Effect.fn("runCommand")(function* ( | ... | @@ -85,8 +95,11 @@ const runCommand = Effect.fn("runCommand")(function* ( |
| 85 | const exitCode = Number(yield* child.exitCode); | 95 | const exitCode = Number(yield* child.exitCode); |
| 86 | | 96 | |
| 87 | if (exitCode !== 0) { | 97 | if (exitCode !== 0) { |
| 88 | return yield* new NativeStaticCheckError({ | 98 | return yield* new NativeStaticCheckCommandError({ |
| 89 | message: `Command exited with non-zero exit code (${exitCode})`, | 99 | command, |
| | 100 | args, |
| | 101 | cwd, |
| | 102 | exitCode, |
| 90 | }); | 103 | }); |
| 91 | } | 104 | } |
| 92 | }); | 105 | }); |