UNPKG

haystack-codegen

Version:

Project Haystack Core code generation tools

41 lines (40 loc) 1.05 kB
"use strict"; /* * Copyright (c) 2021, J2 Innovations. All Rights Reserved */ Object.defineProperty(exports, "__esModule", { value: true }); exports.LibsNode = void 0; /** * Generates exported lib information. */ class LibsNode { newLines = 1; #libs = new Set(); generateCode(out) { const libs = [...this.#libs]; out('/**'); out(' * Libraries used for code generation.'); out(' */'); out(`export const LIBS = [${!libs.length ? ']' : ''}`); if (libs.length) { libs.forEach((lib, i) => { const name = lib.defName; const version = lib.get('version')?.toString() ?? ''; out(' {'); out(` name: '${name}',`); out(` version: '${version}',`); out(' },'); }); out(']'); } } /** * Add a lib def to the node. * * @param lib The lib to add. */ addLib(lib) { this.#libs.add(lib); } } exports.LibsNode = LibsNode;