unity-test-runner/src/model/input.js

36 lines
934 B
JavaScript
Raw Normal View History

2020-01-29 21:22:26 +00:00
import { getInput } from '@actions/core';
import { includes } from 'lodash-es';
class Input {
static get testModes() {
return ['all', 'playmode', 'editmode'];
}
static getFromUser() {
// Input variables specified in workflow using "with" prop.
const unityVersion = getInput('unityVersion') || '2019.2.11f1';
const testMode = getInput('testMode') || 'all';
const rawProjectPath = getInput('testMode') || '.';
const rawArtifactsPath = getInput('testMode') || 'artifacts';
// Validate input
if (!includes(this.testModes, testMode)) {
throw new Error(`Invalid testMode ${testMode}`);
}
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
const artifactsPath = rawArtifactsPath.replace(/\/$/, '');
// Return sanitised input
return {
unityVersion,
projectPath,
testMode,
artifactsPath,
};
}
}
export default Input;