Skip to content

Commit

Permalink
allow env to be passed to python runner
Browse files Browse the repository at this point in the history
  • Loading branch information
sashankaryal committed Aug 14, 2023
1 parent c1d6730 commit c422f2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion e2e-pw/src/shared/python-runner/python-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ dotenv.config({ path: process.env.CI ? ".env.ci" : ".env.dev" });
export type PythonCommandGenerator = (argv: string[]) => string;

export class PythonRunner {
constructor(private pythonCommandGenerator: PythonCommandGenerator) {}
constructor(
private readonly pythonCommandGenerator: PythonCommandGenerator,
private readonly env?: Record<string, string>
) {
this.pythonCommandGenerator = pythonCommandGenerator;

if (this.env) {
Object.entries(this.env).forEach(([key, value]) => {
process.env[key] = value;
});
}
}

public exec(sourceCode: string) {
const dedentedSourceCode = dedentPythonCode(sourceCode);
Expand Down

0 comments on commit c422f2e

Please sign in to comment.