Skip to content

Commit b4879e0

Browse files
authored
feat(run): Support working-directory (#28)
1 parent c951634 commit b4879e0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/package/step.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ describe("stepJSON", () => {
2020
{ kind: "run", name: "test", command: "echo 'Hello, world!'" },
2121
{ name: "test", run: "echo 'Hello, world!'" },
2222
],
23+
[
24+
{
25+
kind: "run",
26+
workingDirectory: "./foo/bar",
27+
command: "echo 'Hello, world!'",
28+
},
29+
{ "working-directory": "./foo/bar", run: "echo 'Hello, world!'" },
30+
],
2331
])("stepJSON(%j) -> %j", (input, expected) => {
2432
expect(stepJSON(input)).toEqual(expected);
2533
});

lib/package/step.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type StepBase = {
1010
export type RunStep = StepBase & {
1111
kind: "run";
1212
command: string;
13-
// TODO: working-directory
13+
workingDirectory?: string;
1414
// TODO: shell
1515
};
1616

@@ -31,7 +31,13 @@ export function stepJSON(step: Step): Record<string, unknown> {
3131

3232
switch (step.kind) {
3333
case "run":
34-
return { ...base, run: step.command };
34+
return {
35+
...base,
36+
...(step.workingDirectory != null && {
37+
"working-directory": step.workingDirectory,
38+
}),
39+
run: step.command,
40+
};
3541
case "uses":
3642
return {
3743
...base,

0 commit comments

Comments
 (0)