Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Add working-directory #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
use-cross:
description: Use cross instead of cargo
default: false
working-directory:
description: Where to start the cargo process
required: false

runs:
using: 'node12'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import stringArgv from "string-argv";
export interface Input {
command: string;
toolchain?: string;
"working-directory"?: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workingDirectory to be consistent with useCross

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. But in all other cases of working directory usage in GH actions (and especially run), it’s used as “working-directory”. So this is consistent with the GH action ecosystem.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoPolo I think working-directory is a good name in YAML but not in JS. For example, the GitHub official action, actions/checkout has input named ssh-key but the name in JS is sshKey.
So I think you should use workingDirectory in JS as @VincentLanglet suggested.

args: string[];
useCross: boolean;
}
Expand All @@ -22,11 +23,13 @@ export function get(): Input {
toolchain = toolchain.slice(1);
}
const useCross = input.getInputBool("use-cross");
const workingDir = input.getInput("working-directory");

return {
command: command,
args: args,
useCross: useCross,
toolchain: toolchain || undefined,
"working-directory": workingDir || undefined
};
}
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export async function run(actionInput: input.Input): Promise<void> {
args.push(actionInput.command);
args = args.concat(actionInput.args);

if (actionInput["working-directory"]) {
process.chdir(path.join(process.cwd(), actionInput["working-directory"]))
}

await program.call(args);
}

Expand Down