"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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const installChecks = require("pnpm-install-checks");
const pnpm_logger_1 = require("pnpm-logger");
const pnpmPkgJson_1 = require("../pnpmPkgJson");
const installCheckLogger = pnpm_logger_1.default('install-check');
function getIsInstallable(pkgId, pkg, fetchedPkg, options) {
    return __awaiter(this, void 0, void 0, function* () {
        const warn = (yield installChecks.checkPlatform(pkg)) || (yield installChecks.checkEngine(pkg, {
            pnpmVersion: pnpmPkgJson_1.default.version,
            nodeVersion: options.nodeVersion
        }));
        if (!warn)
            return true;
        installCheckLogger.warn(warn);
        if (!options.engineStrict && !options.optional)
            return true;
        if (!options.optional)
            throw warn;
        pnpm_logger_1.default.warn({
            message: `Skipping failed optional dependency ${pkgId}`,
            warn,
        });
        return false;
    });
}
exports.default = getIsInstallable;
//# sourceMappingURL=getIsInstallable.js.map