Skip to content

Commit 9db5ca2

Browse files
committed
improve PythonExtension types and logging
1 parent 821fc53 commit 9db5ca2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/build/src/extensions/python.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import fs from "node:fs";
2-
import { $, execa } from "execa";
2+
import { execa } from "execa";
33
import { assert } from "@std/assert";
44
import { additionalFiles } from "@trigger.dev/build/extensions/core";
55
import { BuildManifest } from "@trigger.dev/core/v3";
66
import { BuildContext, BuildExtension } from "@trigger.dev/core/v3/build";
77
import { logger } from "@trigger.dev/sdk/v3";
88

9+
import type { VerboseObject } from "execa";
10+
911
export 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+
3135
const 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
142142
export 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

Comments
 (0)