@guidepup/setup
Version:
Setup your environment for screen-reader automation.
30 lines (29 loc) • 1.05 kB
JavaScript
;
// Derived from https://github.com/sindresorhus/macos-version
// MIT License Copyright (c) Sindre Sorhus
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkVersion = checkVersion;
const fs_1 = require("fs");
const semver_1 = require("semver");
const errors_1 = require("../errors");
function clean(version) {
const { length } = version.split(".");
if (length === 1) {
return `${version}.0.0`;
}
else if (length === 2) {
return `${version}.0`;
}
return version;
}
function checkVersion() {
const plist = (0, fs_1.readFileSync)("/System/Library/CoreServices/SystemVersion.plist", "utf8");
const matches = /<key>ProductVersion<\/key>\s*<string>([\d.]+)<\/string>/.exec(plist);
if (!matches) {
throw new Error(errors_1.ERR_MACOS_UNABLE_TO_VERIFY_VERSION);
}
const version = clean(matches[1].replace("10.16", "11"));
if (!(0, semver_1.satisfies)(version, ">=11.0.0")) {
throw new Error(errors_1.ERR_MACOS_UNSUPPORTED_VERSION);
}
}