Sign in
Explore
Add-ons · HookEveryday codingReviewed

spawn-bin.ts

Shared helper for the hooks: resolves and spawns gstack's bash bins on Windows, and provides a contained runner for external executables.

Kind
Hook
Works with
Claude Code
Languages
TypeScript / JavaScript, Shell
Source
garrytan/gstack @ 01593aa67c94
Path
hosts/claude/hooks/spawn-bin.ts
Jobs
Implementation

Credit

Made by
garrytan
Original
github.com/garrytan/gstack/blob/01593aa67c94780528e8f5121e473…
License
MIT

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • Entries under `hooks` in .claude/settings.json
Runs scripts
Yes
  • spawn-bin.ts
  • the component is a script
Uses the network
None found
Needs secrets
None found
Reads environment variables
  • GSTACK_BASH
Source revision
01593aa67c94
Licence
MIT
Last activity
27 Nov 2026
Source changed after the scan
Yes
  • Last push 27 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

/**
 * Windows-safe resolution + spawn for gstack's bash bins. Two Windows-only
 * bugs made every hook subprocess a silent no-op; both are fixed here so all
 * call sites are covered at once.
 *
 * 1. `new URL(import.meta.url).pathname` yields `/C:/Users/...`; path.resolve
 *    then rebases it onto the drive root as `C:\C:\Users\...`. fileURLToPath
 *    is the correct conversion. (ENOENT before the bin ever ran.)
 * 2. `bin/gstack-*` are extensionless bash scripts. Windows has no shebang
 *    support, so they must be handed to bash explicitly.
 *
 * Also home to runExternal: the contained runner for EXTERNAL executables
 * (third-party binaries a hook hands data to; see its doc comment). Unlike
 * runBin it refuses win32, because its guarantee is process-group containment.
 */
import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
import { spawn, spawnSync, type SpawnSyncOptions } from 'child_process';

// Forward slashes on purpose: Bun's spawnSync on Windows returns ENOENT for a
// backslash exe path containing spaces.
const GIT_BASH = 'C:/Program Files/Git/bin/bash.exe';
…