UNPKG

nav-new-publication-cli

Version:

Add new publication to the navigator web project

46 lines (45 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writePublicationJson = exports.loadJson = void 0; const fs_extra_1 = require("fs-extra"); // import { resolve } from 'path'; const utils_1 = require("./utils"); ; ; const loadJson = async (path, msgs) => { try { const jsonObj = await (0, fs_extra_1.readJson)(path); if (msgs.success) (0, utils_1.logSuccess)(msgs.success); return jsonObj; } catch (err) { if (msgs.error) (0, utils_1.logError)(msgs.error, err); return null; } }; exports.loadJson = loadJson; const writePublicationJson = async (path, publications, data, msgs) => { let newPublication = { title: data.title, export: { vr: data.vr, functional: data.func, }, domain: data.domain, }; if (data.stackAlias) newPublication.stackAlias = data.stackAlias; publications[data.platform].push(newPublication); try { await (0, fs_extra_1.writeJson)(path, publications); if (msgs.success) (0, utils_1.logSuccess)(msgs.success); } catch (err) { if (msgs.error) (0, utils_1.logError)(msgs.error, err); } }; exports.writePublicationJson = writePublicationJson;