"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCoreVersion = void 0;
var path_1 = __importDefault(require("path"));
var fs_1 = __importDefault(require("fs"));
var core = __importStar(require("@serverless-devs/core"));
var semver = require('semver');
var corePath = path_1.default.join(core.getRootHome(), 'cache', 'core');
var corePackagePath = path_1.default.join(corePath, 'package.json');
function getCore() {
    if (fs_1.default.existsSync(corePackagePath)) {
        var localCoreVersion = require('@serverless-devs/core/package.json').version;
        var cacheCoreVersion = getCoreVersion();
        return semver.gt(cacheCoreVersion, localCoreVersion) ? require(corePath) : core;
    }
    return core;
}
function getCoreVersion() {
    return fs_1.default.existsSync(corePackagePath) ? require(corePackagePath).version : undefined;
}
exports.getCoreVersion = getCoreVersion;
exports.default = getCore();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29yZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jb3JlLnRzIl0sIm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