UNPKG

@storm-software/untyped

Version:

A package containing `untyped` utilities for building Storm Software libraries and applications

36 lines (25 loc) 1.59 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _chunkDUNUNFJ4cjs = require('./chunk-DUNUNFJ4.cjs'); var _chunk4G3IU22Jcjs = require('./chunk-4G3IU22J.cjs'); // src/generators/json-schema.ts var _promises = require('fs/promises'); function generateJsonSchemaFile(schema, file, config) { try { const jsonSchema = _chunk4G3IU22Jcjs.getOutputFile.call(void 0, file, "json"); _chunkDUNUNFJ4cjs.writeTrace.call(void 0, `Writing JSON schema file ${jsonSchema}`, config); return _promises.writeFile.call(void 0, jsonSchema, JSON.stringify(schema, null, 2)); } catch (error) { _chunkDUNUNFJ4cjs.writeError.call(void 0, `Error writing JSON schema file for ${file.name} Error: ${_optionalChain([error, 'optionalAccess', _ => _.message]) ? error.message : JSON.stringify(error)}${_optionalChain([error, 'optionalAccess', _2 => _2.stack]) ? ` Stack Trace: ${error.stack}` : ""} Parsed schema: ${JSON.stringify(schema)} `, config ); throw error; } } exports.generateJsonSchemaFile = generateJsonSchemaFile;