"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwIfNotProjectDirectory = exports.isCdktfProjectDirectory = void 0;
// Copyright (c) HashiCorp, Inc
// SPDX-License-Identifier: MPL-2.0
const path = __importStar(require("path"));
const errors_1 = require("../../../lib/errors");
function isCdktfProjectDirectory(directory) {
    try {
        const cdktfPath = path.join(directory, "cdktf.json");
        const cdktf = require(cdktfPath);
        return cdktf.language && cdktf.app;
    }
    catch (_a) {
        return false;
    }
}
exports.isCdktfProjectDirectory = isCdktfProjectDirectory;
function throwIfNotProjectDirectory(directory = process.cwd()) {
    if (!isCdktfProjectDirectory(directory)) {
        throw errors_1.Errors.Usage(`${directory} is not a cdktf project directory, no cdktf.json found or cdktf.json is missing language / app keys`);
    }
}
exports.throwIfNotProjectDirectory = throwIfNotProjectDirectory;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2stZGlyZWN0b3J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY2hlY2stZGlyZWN0b3J5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQkFBK0I7QUFDL0IsbUNBQW1DO0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