"use strict";
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 os_1 = __importDefault(require("os"));
var path_1 = __importDefault(require("path"));
var fs_1 = __importDefault(require("fs"));
var semver = require('semver');
var corePath = path_1.default.join(os_1.default.homedir(), '.s', '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(localCoreVersion, cacheCoreVersion) ? require('@serverless-devs/core') : require(corePath);
    }
    return require('@serverless-devs/core');
}
function getCoreVersion() {
    return fs_1.default.existsSync(corePath) ? require(corePackagePath).version : undefined;
}
exports.getCoreVersion = getCoreVersion;
exports.default = getCore();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29yZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9jb3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLDBDQUFvQjtBQUNwQiw4Q0FBd0I7QUFDeEIsMENBQW9CO0FBQ3BCLElBQU0sTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUVqQyxJQUFNLFFBQVEsR0FBRyxjQUFJLENBQUMsSUFBSSxDQUFDLFlBQUUsQ0FBQyxPQUFPLEVBQUUsRUFBRSxJQUFJLEVBQUUsT0FBTyxFQUFFLE1BQU0sQ0FBQyxDQUFDO0FBQ2hFLElBQU0sZUFBZSxHQUFHLGNBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLGNBQWMsQ0FBQyxDQUFDO0FBRTVELFNBQVMsT0FBTztJQUNkLElBQUksWUFBRSxDQUFDLFVBQVUsQ0FBQyxlQ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