unity-builder/src/model/input.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

import Platform from './platform';
import Versioning from './versioning';
2019-12-22 14:05:15 +00:00
const core = require('@actions/core');
class Input {
static async getFromUser() {
2019-12-22 14:05:15 +00:00
// Input variables specified in workflows using "with" prop.
const version = core.getInput('unityVersion');
const targetPlatform = core.getInput('targetPlatform') || Platform.default;
const rawProjectPath = core.getInput('projectPath') || '.';
const buildName = core.getInput('buildName') || targetPlatform;
const buildsPath = core.getInput('buildsPath') || 'build';
const buildMethod = core.getInput('buildMethod'); // processed in docker file
const versioningStrategy = core.getInput('versioning') || 'Semantic';
const specifiedVersion = core.getInput('version') || '';
2020-01-27 18:39:49 +00:00
const customParameters = core.getInput('customParameters') || '';
2019-12-22 14:05:15 +00:00
// Sanitise input
const projectPath = rawProjectPath.replace(/\/$/, '');
// Parse input
const buildVersion = await Versioning.determineVersion(versioningStrategy, specifiedVersion);
// Return validated input
2019-12-22 14:05:15 +00:00
return {
version,
targetPlatform,
2019-12-22 14:05:15 +00:00
projectPath,
buildName,
buildsPath,
buildMethod,
buildVersion,
2020-01-27 18:39:49 +00:00
customParameters,
2019-12-22 14:05:15 +00:00
};
}
}
export default Input;