mirror of
https://github.com/actions-rs/toolchain.git
synced 2024-11-15 05:56:33 +02:00
Add support for reading toml files
This commit is contained in:
parent
5613870e6d
commit
cebe54f42a
4 changed files with 10181 additions and 19 deletions
10170
package-lock.json
generated
10170
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -35,7 +35,8 @@
|
||||||
"@actions-rs/core": "^0.1.6",
|
"@actions-rs/core": "^0.1.6",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/io": "^1.0.2"
|
"@actions/io": "^1.0.2",
|
||||||
|
"fast-toml": "^0.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.15",
|
"@types/jest": "^26.0.15",
|
||||||
|
|
10
src/args.ts
10
src/args.ts
|
@ -1,6 +1,7 @@
|
||||||
import { input } from "@actions-rs/core";
|
import { input } from "@actions-rs/core";
|
||||||
import { debug } from "@actions/core";
|
import { debug } from "@actions/core";
|
||||||
import { existsSync, readFileSync } from "fs";
|
import { existsSync, readFileSync } from "fs";
|
||||||
|
import { parse } from "fast-toml";
|
||||||
|
|
||||||
export interface ToolchainOptions {
|
export interface ToolchainOptions {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -36,6 +37,15 @@ function determineToolchain(overrideFile: string): string {
|
||||||
flag: "r",
|
flag: "r",
|
||||||
}).trim();
|
}).trim();
|
||||||
|
|
||||||
|
const toolchain = rustToolchainFile.includes("[toolchain]")
|
||||||
|
? parse<{ toolchain?: { channel?: string } }>(rustToolchainFile)
|
||||||
|
?.toolchain?.channel
|
||||||
|
: rustToolchainFile;
|
||||||
|
|
||||||
|
if (!toolchain) {
|
||||||
|
throw new Error(`channel is not specified in ${toolchainPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
debug(`using toolchain from rust-toolchain file: ${rustToolchainFile}`);
|
debug(`using toolchain from rust-toolchain file: ${rustToolchainFile}`);
|
||||||
|
|
||||||
return rustToolchainFile;
|
return rustToolchainFile;
|
||||||
|
|
9
types/fast-toml/index.d.ts
vendored
Normal file
9
types/fast-toml/index.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
declare module "fast-toml" {
|
||||||
|
export function parse<R extends Record<string, unknown>>(input: string): R;
|
||||||
|
export function parseFile<R extends Record<string, unknown>>(
|
||||||
|
file: string
|
||||||
|
): Promise<R>;
|
||||||
|
export function parseFileSync<R extends Record<string, unknown>>(
|
||||||
|
file: string
|
||||||
|
): R;
|
||||||
|
}
|
Loading…
Reference in a new issue