mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 21:40:01 +00:00
Add restore cache.
This commit is contained in:
parent
f6bb205e1d
commit
7b19c2c567
7 changed files with 355 additions and 21 deletions
14
index.ts
14
index.ts
|
@ -1,10 +1,10 @@
|
|||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import TOML from '@ltd/j-toml';
|
||||
import { CARGO_HOME } from './helpers';
|
||||
|
||||
interface Toolchain {
|
||||
channel: string;
|
||||
|
@ -24,14 +24,6 @@ const DEFAULT_TOOLCHAIN: Toolchain = {
|
|||
targets: [],
|
||||
};
|
||||
|
||||
function getCargoHome(): string {
|
||||
if (process.env.CARGO_HOME) {
|
||||
return process.env.CARGO_HOME;
|
||||
}
|
||||
|
||||
return path.join(os.homedir(), '.cargo');
|
||||
}
|
||||
|
||||
function parseConfig(configPath: string): Partial<Toolchain> {
|
||||
const contents = fs.readFileSync(configPath, 'utf8').trim();
|
||||
|
||||
|
@ -184,7 +176,7 @@ async function installBins() {
|
|||
|
||||
core.info('Installing additional binaries');
|
||||
|
||||
const binDir = path.join(getCargoHome(), 'bin');
|
||||
const binDir = path.join(CARGO_HOME, 'bin');
|
||||
|
||||
if (!fs.existsSync(path.join(binDir, 'cargo-binstall'))) {
|
||||
await downloadAndInstallBinstall(binDir);
|
||||
|
@ -213,7 +205,7 @@ async function run() {
|
|||
|
||||
core.info('Adding ~/.cargo/bin to PATH');
|
||||
|
||||
core.addPath(path.join(getCargoHome(), 'bin'));
|
||||
core.addPath(path.join(CARGO_HOME, 'bin'));
|
||||
}
|
||||
|
||||
void run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue