@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
34 lines (25 loc) • 880 B
JavaScript
import fs from 'fs';
import { log } from '@gouvfr/dsfr-forge';
import { DSFRInterpreter } from './dsfr/dsfr-interpreter.js';
import { DSFRArchiveInterpreter } from './dsfr-archive/dsfr-archive-interpreter.js';
class Interpretation {
async interpret (settings) {
log.section('Interpretation');
const interpretation = await this.getInterpretation();
await interpretation.interpret(settings);
}
async getInterpretation () {
const pckFile = fs.readFileSync('package.json');
const pck = JSON.parse(pckFile.toString('utf-8'));
log.info(`package ${pck.name}`);
switch (pck.name) {
case '@gouvfr/dsfr':
return new DSFRInterpreter();
case '@gouvfr/dsfr-archive':
return new DSFRArchiveInterpreter();
default:
throw new Error(`No interpreter found for ${pck.name}`);
}
}
}
export { Interpretation };