"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const modulesController_1 = require("../../fs/modulesController");
const ModulesBreakingChangeError_1 = require("./ModulesBreakingChangeError");
const UnexpectedStoreError_1 = require("./UnexpectedStoreError");
function checkCompatibility(modules, opts) {
    // Important: comparing paths with path.relative()
    // is the only way to compare paths correctly on Windows
    // as of Node.js 4-9
    // See related issue: https://github.com/pnpm/pnpm/issues/996
    if (path.relative(modules.store, opts.storePath) !== '') {
        throw new UnexpectedStoreError_1.default({
            actualStorePath: opts.storePath,
            expectedStorePath: modules.store,
        });
    }
    if (!modules.layoutVersion || modules.layoutVersion !== modulesController_1.LAYOUT_VERSION) {
        throw new ModulesBreakingChangeError_1.default({
            additionalInformation: 'The change was needed to make `independent-leafs` not the default installation layout',
            modulesPath: opts.modulesPath,
            relatedIssue: 821,
        });
    }
}
exports.default = checkCompatibility;
//# sourceMappingURL=index.js.map