"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFileDependencies = getFileDependencies;
const child_process_1 = require("child_process");
/**
 * Returns the list of files that the given file depends on.
 * @param file
 * @param tsConfigPath
 */
function getFileDependencies(file, tsConfigPath) {
    return __awaiter(this, void 0, void 0, function* () {
        const { toList: files } = yield Promise.resolve().then(() => require('dependency-tree'));
        const tsConfig = JSON.parse((0, child_process_1.execSync)(`tsc -p ${tsConfigPath} --showConfig`).toString());
        return files({
            filename: file,
            tsConfig: {
                compilerOptions: {
                    paths: tsConfig.compilerOptions.paths
                }
            },
            filter: (path) => path.indexOf('node_modules') === -1,
            directory: process.cwd()
        });
    });
}
//# sourceMappingURL=get-file-dependencies.js.map