@@ -2,7 +2,7 @@ import { $ } from "bun";
22import { confirm , input , select } from "@inquirer/prompts" ;
33import type { CAC } from "cac" ;
44import chalk from "chalk" ;
5- import { cpSync , existsSync , mkdirSync , mkdtempSync , readFileSync , rmSync , writeFileSync } from "node:fs" ;
5+ import { copyFileSync , cpSync , existsSync , mkdirSync , mkdtempSync , readFileSync , rmSync , writeFileSync } from "node:fs" ;
66import { join } from "node:path" ;
77import { tmpdir } from "node:os" ;
88import { stringify } from "yaml" ;
@@ -138,6 +138,15 @@ function syncBundleArtifacts(bundleDir: string, repoDir: string): void {
138138 cpSync ( sourceDir , join ( repoDir , "dist" ) , { recursive : true , force : true } ) ;
139139}
140140
141+ function stageRunningBinary ( repoDir : string ) : void {
142+ if ( ! process . execPath || ! existsSync ( process . execPath ) ) {
143+ return ;
144+ }
145+ const targetDir = join ( repoDir , "dist" ) ;
146+ mkdirSync ( targetDir , { recursive : true } ) ;
147+ copyFileSync ( process . execPath , join ( targetDir , "terrariumctl" ) ) ;
148+ }
149+
141150function localSourcePath ( repoUrl : string ) : string {
142151 if ( repoUrl . startsWith ( "file://" ) ) {
143152 return repoUrl . slice ( "file://" . length ) ;
@@ -177,6 +186,9 @@ async function prepareRepo(ref: string): Promise<void> {
177186 }
178187
179188 syncBundleArtifacts ( BUNDLE_DIR , REPO_DIR ) ;
189+ if ( ! existsSync ( join ( REPO_DIR , "dist" , "terrariumctl" ) ) ) {
190+ stageRunningBinary ( REPO_DIR ) ;
191+ }
180192 if ( ! existsSync ( join ( REPO_DIR , "dist" , "terrariumctl" ) ) ) {
181193 fail ( "compiled Terrarium binaries are missing from the repository checkout" ) ;
182194 }
0 commit comments