Files
android-emulator-runner/lib/main.js
T
2019-11-06 22:14:03 +11:00

54 lines
2.5 KiB
JavaScript

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const sdk_installer_1 = require("./sdk-installer");
const input_validator_1 = require("./input-validator");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
// only support running on macOS
if (process.platform !== 'darwin') {
throw new Error('This action is expected to be run within a macOS virtual machine to enable hardware acceleration.');
}
// API level of the platform and system image
const apiLevel = core.getInput('api-level', { required: true });
input_validator_1.checkApiLevel(apiLevel);
console.log(`API level: ${apiLevel}`);
// target of the system image
const target = core.getInput('target');
input_validator_1.checkTarget(target);
console.log(`target: ${target}`);
// CPU / ABI of the system image
const abi = core.getInput('abi');
input_validator_1.checkAbi(abi);
console.log(`cpu/abi: ${abi}`);
// headless mode
const headless = core.getInput('headless');
input_validator_1.checkHeadless(headless);
console.log(`headless mode: ${headless}`);
// install SDK
yield sdk_installer_1.installAndroidSdk(Number(apiLevel), target, abi);
// TODO start emulator
}
catch (error) {
core.setFailed(error.message);
}
});
}
run();