"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Utils = __importStar(require("../../../util/src"));
const Path = __importStar(require("path"));
const FS = __importStar(require("fs"));
const Mustache = __importStar(require("mustache"));
function report(reports) {
    Utils.Console.info(`开始处理报告 ...`);
    const path = Path.join(process.env.HOME ? process.env.HOME : '', 'Desktop/RubikCaseReport.md');
    const successReports = new Array();
    const failureReports = new Array();
    for (const report of reports) {
        let hasFailured = false;
        for (const portrait of report.portraits) {
            if (!portrait.success) {
                hasFailured = true;
                break;
            }
        }
        if (hasFailured) {
            failureReports.push(report);
        }
        else {
            successReports.push(report);
        }
    }
    const view = FS.readFileSync((Path.join(Utils.ACUtils.respath, 'case/report.md'))).toString();
    const data = {
        date: Utils.now(),
        successReports,
        failureReports
    };
    FS.writeFileSync(path, Mustache.render(view, data));
    Utils.Console.info(`结果报告已生成，详情请参阅 [${path}]`);
    return Promise.resolve();
}
exports.report = report;
//# sourceMappingURL=report.js.map