"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2020 Plexus Interop Deutsche Bank AG
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var cli_1 = require("protobufjs/cli");
var os = require("os");
var path = require("path");
var files_1 = require("../common/files");
function genJsStaticModule(outFilePath, protoFiles, namespace) {
    return new Promise(function (resolve, reject) {
        cli_1.pbjs.main(tslib_1.__spreadArrays(['--force-long', '--no-delimited', '--sparse', '-t', 'static-module', '-r', namespace, '-w', 'commonjs', '-o', outFilePath], protoFiles), function (error, output) {
            if (error) {
                reject(error);
            }
            else {
                resolve();
            }
            return {};
        });
    });
}
exports.genJsStaticModule = genJsStaticModule;
function getPbJsExecPath() {
    return path.resolve(files_1.getBaseDir(), 'node_modules', '.bin', os.platform() === 'win32' ? 'pbjs.cmd' : 'pbjs');
}
exports.getPbJsExecPath = getPbJsExecPath;
function genTsStaticModule(outFilePath, jsGeneratedFilePath) {
    return new Promise(function (resolve, reject) {
        cli_1.pbts.main(['--force-long', '-o', outFilePath, jsGeneratedFilePath], function (error, output) {
            if (error) {
                reject(error);
            }
            else {
                resolve();
            }
            return {};
        });
    });
}
exports.genTsStaticModule = genTsStaticModule;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdG9Kcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tb24vcHJvdG9Kcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQ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