"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Copyright 2017-2018 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(['--force-long', '--no-delimited', '--sparse', '-t', 'static-module', '-r', namespace, '-w', 'commonjs', '-o', outFilePath].concat(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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdG9Kcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tb24vcHJvdG9Kcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0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