Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function main() {

const instance = await sandbox.create();

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

const url = await instance.exposePort(3000);
console.log(`Server is running at ${url}`);
Expand Down
9 changes: 7 additions & 2 deletions lib/resources/abstraction/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
PodSandboxCreateDirectoryResponse,
PodSandboxListUrlsResponse,
PodInstanceData,
ExecOptions,
} from "../../types/pod";
import beamClient from "../..";

Expand Down Expand Up @@ -430,8 +431,12 @@ export class SandboxInstance extends PodInstance {
}

/** Run an arbitrary command in the sandbox. */
public async exec(...args: string[]): Promise<SandboxProcess> {
return this._exec(args);
public async exec(
command: string | string[],
opts?: ExecOptions
): Promise<SandboxProcess> {
const commandList = Array.isArray(command) ? command : [command];
return this._exec(commandList, opts);
}

private async _exec(
Expand Down
5 changes: 5 additions & 0 deletions lib/types/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,9 @@ export interface PodSandboxCreateImageFromFilesystemResponse {
imageId: string;
}

export interface ExecOptions {
cwd?: string;
env?: Record<string, string>;
}

// Store requests here?