"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const error_1 = require("../../server/metadata/error");
const extractor_1 = require("../../server/metadata/extractor");
function default_1(options) {
    return __awaiter(this, void 0, void 0, function* () {
        const extractor = new extractor_1.MetadataExtractor();
        try {
            yield extractor.compile(options.project.baseDir());
        }
        catch (e) {
            if (e instanceof error_1.DeclarationError) {
                process.stdout.write(JSON.stringify(e, null, 2));
                process.exit(1);
            }
            throw e;
        }
        process.stdout.write(JSON.stringify(extractor.gatherResult(), null, 2));
        process.stdout.write('\n');
    });
}
exports.default = default_1;
