UNPKG

@gouvfr/dsfr-nexus

Version:

Le module `dsfr-nexus` est l'interface de ligne de commande (CLI) centrale du Système de Design de l’État - DSFR. Il offre des outils pour gérer et compiler les ressources du DSFR

41 lines (35 loc) 875 B
import { log } from '@gouvfr/dsfr-forge'; import fs from 'fs'; import yaml from 'yaml'; class MeshItem { constructor (state, path) { this._path = path; this._state = state; this._isValid = false; } async read () { this._item = this._state.resolveItem({ path: this._path }); if (!this._item.config) return; const ymlFile = fs.readFileSync(this._item.config, 'utf8'); const yml = yaml.parse(ymlFile); if (!yml) { log.error(`MeshItem: Invalid item at ${this._path}`); return; } this._isValid = true; this._description = yml.description || ''; this._cover = yml.cover } get data () { return { url: this._item.url, text: this._item.text, shortDescription: this._description, cover: this._cover, } } get isValid () { return this._isValid; } } export { MeshItem };