UNPKG

@tangelo/tangelo-configuration-toolkit

Version:

Tangelo Configuration Toolkit is a command-line toolkit which offers support for developing a Tangelo configuration.

41 lines (32 loc) 1.23 kB
const fs = require('fs-extra'); const path = require('path'); const TclConfig = require('./tcl-config'); const through2 = require('through2'); const Vinyl = require('vinyl'); function createAddToStreamFn(stream) { return (path, content) => stream.push(new Vinyl({ path: path, contents: Buffer.from(content) })); } module.exports = function() { const tclFileDirs = []; return through2.obj( function transform (file, _, cb) { if (file.isStream()) return cb(new Error('Streaming not supported.')); if (file.extname == '.tcl') tclFileDirs.push(path.dirname(file.relative)); return cb(null, file); }, function flush(cb) { for (const tclFileDir of tclFileDirs) { const tclConfig = new TclConfig(tclFileDir, createAddToStreamFn(this)); tclConfig.outputJson(path.resolve(tclFileDir, 'fonto/assets')); tclConfig.outputCss(path.resolve(tclFileDir, 'fonto')); const esefCssDir = path.resolve(tclFileDir, 'export/esef/esef_out/css'); if (fs.existsSync(esefCssDir)) tclConfig.outputCss(esefCssDir); } cb(); } ) .resume(); // required for triggering 'end' event };