add working-directory option

This commit is contained in:
Adam Curtis 2023-01-31 17:25:10 -05:00
parent 88dc235639
commit e80cf306a4
5 changed files with 10162 additions and 15 deletions

View File

@ -28,6 +28,8 @@ inputs:
components: components:
description: Comma-separated list of components to be additionally installed for a new toolchain description: Comma-separated list of components to be additionally installed for a new toolchain
required: false required: false
working-directory:
description: Working directory to use for finding rust-toolchain
outputs: outputs:
rustc: rustc:

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

10165
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,13 @@ function determineToolchain(overrideFile: string): string {
return rustToolchainFile; return rustToolchainFile;
} }
export function setWorkingDirectory() {
const workingDirectory = input.getInput("working-directory");
if (workingDirectory) {
process.chdir(workingDirectory);
}
}
export function getToolchainArgs(overrideFile: string): ToolchainOptions { export function getToolchainArgs(overrideFile: string): ToolchainOptions {
let components: string[] | undefined = input.getInputList("components"); let components: string[] | undefined = input.getInputList("components");
if (components && components.length === 0) { if (components && components.length === 0) {

View File

@ -6,6 +6,7 @@ import * as versions from "./versions";
import { RustUp, ToolchainOptions } from "@actions-rs/core"; import { RustUp, ToolchainOptions } from "@actions-rs/core";
async function run(): Promise<void> { async function run(): Promise<void> {
args.setWorkingDirectory();
// we use path.join to make sure this works on Windows, Linux and MacOS // we use path.join to make sure this works on Windows, Linux and MacOS
const toolchainOverridePath = path.join(process.cwd(), "rust-toolchain"); const toolchainOverridePath = path.join(process.cwd(), "rust-toolchain");