@baseplate-dev/sync
Version:
Library for syncing Baseplate descriptions
22 lines • 1.16 kB
JavaScript
import { stringifyPrettyCompact } from '@baseplate-dev/utils';
import path from 'node:path';
/**
* Writes extractor.json files for the specified generators to the file system.
* This function reads the current configurations from the context and writes them
* to their respective extractor.json files.
*
* @param generatorNames - Array of generator names to write extractor.json files for
* @param context - Template extractor context containing config lookup and file container
* @throws Error if no config is found for a generator
*/
export async function writeExtractorTemplateJsons(generatorNames, context) {
for (const generator of generatorNames) {
const generatorConfig = context.configLookup.getExtractorConfig(generator);
if (!generatorConfig) {
throw new Error(`No 'extractor.json' found for generator: ${generator}`);
}
// Write the config to the extractor.json file
await context.fileContainer.writeFile(path.join(generatorConfig.generatorDirectory, 'extractor.json'), stringifyPrettyCompact(generatorConfig.config));
}
}
//# sourceMappingURL=write-extractor-template-jsons.js.map