"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genTsStaticModule = exports.getPbJsExecPath = exports.genJsStaticModule = void 0;
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2022 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 os = require("os");
var path = require("path");
var cli_1 = require("protobufjs/cli");
var files_1 = require("./files");
function genJsStaticModule(outFilePath, protoFiles, namespace) {
    return new Promise(function (resolve, reject) {
        cli_1.pbjs.main((0, tslib_1.__spreadArray)([
            '--force-long',
            '--no-delimited',
            '--sparse',
            '-t',
            'static-module',
            '-r',
            namespace,
            '-w',
            'commonjs',
            '-o',
            outFilePath
        ], protoFiles, true), function (error) {
            if (error) {
                reject(error);
            }
            else {
                resolve();
            }
            return {};
        });
    });
}
exports.genJsStaticModule = genJsStaticModule;
function getPbJsExecPath() {
    return path.resolve((0, 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) {
            if (error) {
                reject(error);
            }
            else {
                resolve();
            }
            return {};
        });
    });
}
exports.genTsStaticModule = genTsStaticModule;
//# sourceMappingURL=protoJs.js.map