"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var common_1 = require("../common");
var ELECTRON = common_1.constants.PATH.ELECTRON;
var WEB = common_1.constants.PATH.WEB;
function stats(args) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var prod, targets;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    prod = args.prod;
                    targets = Array.isArray(args.target) ? args.target : [args.target];
                    if (!targets.includes('electron')) return [3, 5];
                    return [4, logDir(ELECTRON.MAIN.OUT_DIR)];
                case 1:
                    _a.sent();
                    if (!(prod === undefined || prod === false)) return [3, 3];
                    return [4, logDir(ELECTRON.RENDERER.OUT_DIR.DEV)];
                case 2:
                    _a.sent();
                    _a.label = 3;
                case 3:
                    if (!(prod === undefined || prod === true)) return [3, 5];
                    return [4, logDir(ELECTRON.RENDERER.OUT_DIR.PROD)];
                case 4:
                    _a.sent();
                    _a.label = 5;
                case 5:
                    if (!targets.includes('web')) return [3, 9];
                    if (!(prod === undefined || prod === false)) return [3, 7];
                    return [4, logDir(WEB.OUT_DIR.DEV)];
                case 6:
                    _a.sent();
                    _a.label = 7;
                case 7:
                    if (!(prod === undefined || prod === true)) return [3, 9];
                    return [4, logDir(WEB.OUT_DIR.PROD)];
                case 8:
                    _a.sent();
                    _a.label = 9;
                case 9: return [2];
            }
        });
    });
}
exports.stats = stats;
function logDir(dir) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var res, total;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    dir = common_1.fsPath.resolve(dir);
                    return [4, common_1.fs.pathExists(dir)];
                case 1:
                    if (!(_a.sent())) {
                        return [2];
                    }
                    return [4, common_1.logging.fileStatsTable({ dir: dir })];
                case 2:
                    res = _a.sent();
                    total = res.total;
                    common_1.log.info.gray(common_1.logging.formatPath(dir, true) + " (" + total.size + ")");
                    res.table.log();
                    common_1.log.info();
                    return [2];
            }
        });
    });
}
//# sourceMappingURL=stats.js.map