@@ -152,6 +152,7 @@ async function runCommand(command: string, args: string[], cwd?: string) {
152152 await new Promise < void > ( ( resolve , reject ) => {
153153 const child = spawn ( command , args , {
154154 cwd,
155+ env : process . env ,
155156 stdio : "inherit" ,
156157 } ) ;
157158
@@ -170,6 +171,20 @@ async function runCommand(command: string, args: string[], cwd?: string) {
170171 } ) ;
171172}
172173
174+ async function syncOptionalDependenciesForTarget ( spec : TargetSpec ) {
175+ await runCommand (
176+ "bun" ,
177+ [
178+ "install" ,
179+ "--frozen-lockfile" ,
180+ "--ignore-scripts" ,
181+ `--os=${ spec . os } ` ,
182+ `--cpu=${ spec . cpu } ` ,
183+ ] ,
184+ REPO_ROOT ,
185+ ) ;
186+ }
187+
173188function unixLauncher ( binaryName : "ralph" | "ralphd" ) {
174189 return `#!/usr/bin/env bash
175190set -e
@@ -265,6 +280,7 @@ export async function buildBinaries(
265280 for ( const target of targets ) {
266281 const spec = getTargetSpec ( target ) ;
267282 const targetDir = join ( outDir , target ) ;
283+ await syncOptionalDependenciesForTarget ( spec ) ;
268284 await rm ( targetDir , { recursive : true , force : true } ) ;
269285 await mkdir ( targetDir , { recursive : true } ) ;
270286
@@ -480,6 +496,9 @@ export async function publishDistribution(
480496 console . log ( `(dry-run) cwd=${ packageDir } bun ${ args . join ( " " ) } ` ) ;
481497 continue ;
482498 }
499+ if ( ! process . env . NPM_CONFIG_TOKEN && process . env . NPM_TOKEN ) {
500+ process . env . NPM_CONFIG_TOKEN = process . env . NPM_TOKEN ;
501+ }
483502 await runCommand ( "bun" , args , packageDir ) ;
484503 }
485504}
0 commit comments