"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var common_1 = require("./common");
function copyResources() {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var copy;
        var _this = this;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    copy = function (options) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
                        var from, to, error_1;
                        return tslib_1.__generator(this, function (_a) {
                            switch (_a.label) {
                                case 0:
                                    from = options.from, to = options.to;
                                    common_1.log.info.magenta("Copy " + common_1.log.cyan('editor.code') + " resources\n");
                                    common_1.log.info.gray(" FROM: " + common_1.log.white(from));
                                    common_1.log.info.gray(" TO:   " + common_1.log.white(to));
                                    _a.label = 1;
                                case 1:
                                    _a.trys.push([1, 3, , 4]);
                                    return [4, common_1.fs.copy(from, to)];
                                case 2:
                                    _a.sent();
                                    return [2, { success: true }];
                                case 3:
                                    error_1 = _a.sent();
                                    common_1.log.error("Failed to copy resources from " + from);
                                    return [2, { success: false, error: error_1 }];
                                case 4: return [2];
                            }
                        });
                    }); };
                    return [4, copy({
                            from: common_1.fsPath.join(common_1.constants.EDITOR_RESOURCES.SOURCE, 'external'),
                            to: common_1.constants.EDITOR_RESOURCES.HOST,
                        })];
                case 1:
                    _a.sent();
                    common_1.log.info();
                    return [2];
            }
        });
    });
}
exports.copyResources = copyResources;
function copyEcmascriptDefs() {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var FROM_DIR, TO_DIR, paths, _i, paths_1, from, filename, to;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    FROM_DIR = common_1.constants.ECMASCRIPT_DEFS.SOURCE;
                    TO_DIR = common_1.constants.ECMASCRIPT_DEFS.LOCAL;
                    return [4, common_1.glob.find(FROM_DIR + "/*.d.ts")];
                case 1:
                    paths = _a.sent();
                    common_1.log.info.magenta("Copy " + common_1.log.cyan('ECMAScript') + " language defs (\".d.ts\" files)\n");
                    common_1.log.info.gray(" FROM: " + common_1.log.white(FROM_DIR));
                    common_1.log.info.gray(" TO:   " + common_1.log.white(TO_DIR));
                    _i = 0, paths_1 = paths;
                    _a.label = 2;
                case 2:
                    if (!(_i < paths_1.length)) return [3, 5];
                    from = paths_1[_i];
                    filename = common_1.fsPath.basename(from);
                    to = common_1.fsPath.join(TO_DIR, filename);
                    return [4, common_1.fs.copy(from, to)];
                case 3:
                    _a.sent();
                    _a.label = 4;
                case 4:
                    _i++;
                    return [3, 2];
                case 5:
                    common_1.log.info();
                    return [2];
            }
        });
    });
}
exports.copyEcmascriptDefs = copyEcmascriptDefs;
//# sourceMappingURL=copy.js.map