@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
33 lines (24 loc) • 776 B
JavaScript
import { getStates } from '../../common/state/state.js';
import { PartInterpreter } from './part/part-interpreter.js';
class DsfrInterpreter {
async interpret (settings) {
const states = await getStates();
for (const state of states) {
await this._interpret(settings, state);
}
}
async _interpret (settings, state) {
const partIds = settings.partIds ? state.partIds.filter(id => settings.partIds.includes(id)) : state.partIds;
this._parts = [];
for (const id of partIds) {
const partState = state.setPart(id);
const part = new PartInterpreter(partState);
this._parts.push(part);
await part.read();
}
for (const part of this._parts) {
await part.write();
}
}
}
export { DsfrInterpreter };