forked from actions/setup-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.ts
More file actions
26 lines (20 loc) · 849 Bytes
/
installer.ts
File metadata and controls
26 lines (20 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import * as path from 'path';
const IS_WINDOWS = process.platform === 'win32';
export async function findRubyVersion(version: string) {
const installDir: string | null = tc.find('Ruby', version);
if (!installDir) {
throw new Error(`Version ${version} not found`);
}
const toolPath: string = path.join(installDir, 'bin');
if (!IS_WINDOWS) {
// Ruby / Gem heavily use the '#!/usr/bin/ruby' to find ruby, so this task needs to
// replace that version of ruby so all the correct version of ruby gets selected
// replace the default
const dest: string = '/usr/bin/ruby';
exec.exec('sudo ln', ['-sf', path.join(toolPath, 'ruby'), dest]); // replace any existing
}
core.addPath(toolPath);
}