eslint-plugin-json-schema-validator
Version:
ESLint plugin that validates data using JSON Schema Validator.
35 lines (34 loc) • 1.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.syncGet = void 0;
const child_process_1 = require("child_process");
const path_1 = __importDefault(require("path"));
function syncGet(url, options, httpModulePath) {
const httpScriptPath = require.resolve("./cli");
const execPath = process.execPath;
const optionsJSON = JSON.stringify(options !== null && options !== void 0 ? options : {});
const cliArgs = [
httpScriptPath,
url,
optionsJSON,
JSON.stringify({ httpModulePath }),
];
if (path_1.default.extname(httpScriptPath) === ".ts") {
cliArgs.unshift("--require", "ts-node/register/transpile-only");
}
const result = child_process_1.spawnSync(execPath, cliArgs, {
windowsHide: true,
maxBuffer: Infinity,
});
if (result.error) {
throw result.error;
}
if (result.status !== 0) {
throw new Error(`Failed:\n${result.stdout.toString()}\n${result.stderr.toString()}`);
}
return result.stdout.toString("utf8");
}
exports.syncGet = syncGet;