Skip to content

Commit beb301d

Browse files
authored
Add Opts to exec (#41)
1 parent 6db0990 commit beb301d

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function main() {
6666

6767
const instance = await sandbox.create();
6868

69-
const process4 = await instance.exec("sh", "-c", "cd /app && node server.js");
69+
const process4 = await instance.exec(["sh", "-c", "cd /app && node server.js"]);
7070

7171
const url = await instance.exposePort(3000);
7272
console.log(`Server is running at ${url}`);

lib/resources/abstraction/sandbox.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
PodSandboxCreateDirectoryResponse,
1313
PodSandboxListUrlsResponse,
1414
PodInstanceData,
15+
ExecOptions,
1516
} from "../../types/pod";
1617
import beamClient from "../..";
1718

@@ -430,8 +431,12 @@ export class SandboxInstance extends PodInstance {
430431
}
431432

432433
/** Run an arbitrary command in the sandbox. */
433-
public async exec(...args: string[]): Promise<SandboxProcess> {
434-
return this._exec(args);
434+
public async exec(
435+
command: string | string[],
436+
opts?: ExecOptions
437+
): Promise<SandboxProcess> {
438+
const commandList = Array.isArray(command) ? command : [command];
439+
return this._exec(commandList, opts);
435440
}
436441

437442
private async _exec(

lib/types/pod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,9 @@ export interface PodSandboxCreateImageFromFilesystemResponse {
299299
imageId: string;
300300
}
301301

302+
export interface ExecOptions {
303+
cwd?: string;
304+
env?: Record<string, string>;
305+
}
306+
302307
// Store requests here?

0 commit comments

Comments
 (0)