@whisklabs/grpc
Version:
gRPC generator and http library for typescript
45 lines • 2.35 kB
JavaScript
;
/* eslint-disable camelcase */
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
var typeguards_1 = require("@whisklabs/typeguards");
var fs_1 = require("fs");
var path_1 = require("path");
var main_1 = require("./main");
var _c = process.env, PROTO_DIR = _c.PROTO_DIR, PROTO_OUT = _c.PROTO_OUT, PROTO_EXCLUDE = _c.PROTO_EXCLUDE, PROTO_VERSION = _c.PROTO_VERSION, PROTO_DEBUG = _c.PROTO_DEBUG, PROTO_PACKAGE_NAME = _c.PROTO_PACKAGE_NAME, PROTO_PACKAGE_VERSION = _c.PROTO_PACKAGE_VERSION, PROTO_PACKAGE_URL = _c.PROTO_PACKAGE_URL, PROTO_PACKAGE_REGISTRY = _c.PROTO_PACKAGE_REGISTRY, PROTO_MESSAGE_REQUIRED = _c.PROTO_MESSAGE_REQUIRED, npm_package_devDependencies__whisklabs_grpc = _c.npm_package_devDependencies__whisklabs_grpc, npm_package_dependencies__whisklabs_grpc = _c.npm_package_dependencies__whisklabs_grpc;
if (!(0, typeguards_1.isText)(PROTO_DIR)) {
throw new Error('No PROTO_DIR input folder');
}
if (!(0, typeguards_1.isText)(PROTO_OUT)) {
throw new Error('No PROTO_OUT out folder');
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(0, main_1.generator)({
dir: PROTO_DIR,
out: PROTO_OUT,
version: (0, typeguards_1.isText)(PROTO_VERSION)
? PROTO_VERSION
: (_b = (_a = findRoot()) !== null && _a !== void 0 ? _a : npm_package_devDependencies__whisklabs_grpc) !== null && _b !== void 0 ? _b : npm_package_dependencies__whisklabs_grpc,
exclude: (0, typeguards_1.isText)(PROTO_EXCLUDE) ? new RegExp(PROTO_EXCLUDE) : undefined,
messageRequired: (0, typeguards_1.isPresent)(PROTO_MESSAGE_REQUIRED),
debug: PROTO_DEBUG === 'true',
packageName: PROTO_PACKAGE_NAME,
packageVersion: PROTO_PACKAGE_VERSION,
packageUrl: PROTO_PACKAGE_URL,
packageRegistry: PROTO_PACKAGE_REGISTRY,
}).then(function (error) { return process.exit(error ? 1 : 0); });
function findRoot() {
var _a;
var path = __dirname;
var file = 'package.json';
while (!(0, fs_1.existsSync)((0, path_1.join)(path, file))) {
if (path === process.cwd()) {
return undefined;
}
path = (0, path_1.join)(path, '..');
}
// eslint-disable-next-line
return (_a = require((0, path_1.join)(path, file))) === null || _a === void 0 ? void 0 : _a.version;
}
//# sourceMappingURL=cli.js.map