11import fs from "node:fs" ;
2- import { $ , execa } from "execa" ;
2+ import { execa } from "execa" ;
33import { assert } from "@std/assert" ;
44import { additionalFiles } from "@trigger.dev/build/extensions/core" ;
55import { BuildManifest } from "@trigger.dev/core/v3" ;
66import { BuildContext , BuildExtension } from "@trigger.dev/core/v3/build" ;
77import { logger } from "@trigger.dev/sdk/v3" ;
88
9+ import type { VerboseObject } from "execa" ;
10+
911export type PythonOptions = {
1012 requirements ?: string [ ] ;
1113 requirementsFile ?: string ;
@@ -28,6 +30,8 @@ export type PythonOptions = {
2830 scripts ?: string [ ] ;
2931} ;
3032
33+ type ExecaOptions = Parameters < typeof execa > [ 1 ] ;
34+
3135const splitAndCleanComments = ( str : string ) =>
3236 str
3337 . split ( "\n" )
@@ -114,17 +118,13 @@ class PythonExtension implements BuildExtension {
114118 }
115119}
116120
117- export const run = async ( scriptArgs : string [ ] = [ ] , options : Parameters < typeof $ > [ 1 ] = { } ) => {
121+ export const run = async ( scriptArgs : string [ ] = [ ] , options : ExecaOptions = { } ) => {
118122 const pythonBin = process . env . PYTHON_BIN_PATH || "python" ;
119123
120- logger . debug (
121- `Running ${ pythonBin } \t${ JSON . stringify ( scriptArgs ) } ${ options . input ? `(with stdin)` : "" } ` ,
122- options
123- ) ;
124-
125124 const result = await execa ( {
126125 shell : true ,
127- verbose : ( verboseLine , verboseObject ) => logger . debug ( verboseLine , verboseObject ) ,
126+ verbose : ( verboseLine : string , verboseObject : VerboseObject ) =>
127+ logger . debug ( verboseObject . message , verboseObject ) ,
128128 ...options ,
129129 } ) ( pythonBin , scriptArgs ) ;
130130
@@ -142,15 +142,15 @@ export const run = async (scriptArgs: string[] = [], options: Parameters<typeof
142142export const runScript = (
143143 scriptPath : string ,
144144 scriptArgs : string [ ] = [ ] ,
145- options : Parameters < typeof $ > [ 1 ] = { }
145+ options : ExecaOptions = { }
146146) => {
147147 assert ( scriptPath , "Script path is required" ) ;
148148 assert ( fs . existsSync ( scriptPath ) , `Script does not exist: ${ scriptPath } ` ) ;
149149
150150 return run ( [ scriptPath , ...scriptArgs ] , options ) ;
151151} ;
152152
153- export const runInline = ( scriptContent : string , options : Parameters < typeof $ > [ 1 ] = { } ) => {
153+ export const runInline = ( scriptContent : string , options : ExecaOptions = { } ) => {
154154 assert ( scriptContent , "Script content is required" ) ;
155155
156156 return run ( [ "" ] , { input : scriptContent , ...options } ) ;
0 commit comments