UNPKG

@fontoxml/fontoxml-development-tools

Version:
41 lines (34 loc) 981 B
'use strict'; const path = require('path'); const getParentDirectoryContainingFileSync = require('./getParentDirectoryContainingFileSync'); module.exports = function enrichRequestObject (app) { const editorRepositoryPath = getParentDirectoryContainingFileSync(process.cwd(), 'manifest.json'); const editorRepository = { path: editorRepositoryPath, name: null, sdkVersion: null, config: null, throwIfNotInsideEditorRepository: () => { if (!editorRepositoryPath) { throw new app.cli.InputError( 'Not running from inside an editor repository.', 'This command needs to be run from inside an editor repository.'); } } }; try { Object.assign(editorRepository, require(path.join(editorRepository.path, 'manifest.json'))); } catch (_error) { // No-op } try { editorRepository.config = require(path.join(editorRepository.path, 'config.json')); } catch (_error) { // No-op } app.request.fdt = { editorRepository }; };