Skip to content

Commit

Permalink
Support ruby_version
Browse files Browse the repository at this point in the history
  • Loading branch information
masa-iwasaki committed Nov 4, 2019
1 parent 50f3cc9 commit e1a9bd1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/setup-ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ 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');
}
console.log(`ruby-version: ${version}`);
yield installer_1.findRubyVersion(version);
}
catch (error) {
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) {
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);
}

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

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

0 comments on commit e1a9bd1

Please sign in to comment.