Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Support .ruby_version #37

Closed
Closed
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
12 changes: 12 additions & 0 deletions lib/setup-ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const installer_1 = require("./installer");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
let version = core.getInput('version');
if (!version) {
const options = {};
// Ignore stderr because there is a fallback
// option to "ruby_version" parameter.
options.listeners = {
stdout: (data) => {
version += data.toString();
}
};
yield exec.exec('cat', ['.ruby-version'], options);
}
if (!version) {
version = core.getInput('ruby-version');
}
Expand Down
18 changes: 18 additions & 0 deletions src/setup-ruby.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {ExecOptions} from '@actions/exec/lib/interfaces';
import {findRubyVersion} from './installer';

async function run() {
try {
let version = core.getInput('version');

if (!version) {
version = core.getInput('ruby-version');
}

if (!version) {
const options: ExecOptions = {};

// Ignore stderr because there is a fallback
// option to "ruby_version" parameter.
options.listeners = {
stdout: (data: Buffer) => {
version += data.toString();
}
};

await exec.exec('cat', ['.ruby-version'], options);
}

await findRubyVersion(version);
} catch (error) {
core.setFailed(error.message);
Expand Down