bin.ts
This file
Path
apps/cli/src/bin.ts
25 lines · 966 bytes · TypeScript
Last changed by
Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
History of this fileTake it
The walk stopped after 200 commits: lines older than 10c8b54 point at it.
Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
line 1why, one step back1#!/usr/bin/env nodeMerge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 2why, one step back2// One file plays two roles, chosen by the name it was started by: the CLI, and git's credential helper.Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 3–10why, one step back3import { BunRuntime, BunServices } from "@effect/platform-bun";4import { Brand } from "@repo/brand";5import { Effect, Layer, Path, Stdio } from "effect";67import { CliServices, program } from "./main.ts";89const live = CliServices.pipe(Layer.provideMerge(BunServices.layer));10Merge build/comments-cli-protocol-checks into mainoscabrielbefore adoptionc86204f
line 11why, one step back11/** The compiled binary keeps its link's name in `argv0`; Node or Bun through an npm bin link keep it in `argv[1]`. */Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 12–25why, one step back12const startedAs = Effect.map(Path.Path, (path) =>13 [process.argv0, process.argv[1]].map((name) => path.basename(name ?? ""))14);1516const main = Effect.gen(function* () {17 const names = yield* startedAs;18 const args = yield* Effect.flatMap(Stdio.Stdio, (stdio) => stdio.args);1920 return yield* program(21 names.includes(Brand.gitCredentialHelper) ? ["credential", ...args] : args22 );23});2425BunRuntime.runMain(main.pipe(Effect.provide(live)));