const renderer = require('sdftosvg');
const uuidv4 = require('uuid/v4');
const fs = require('fs');

function convert(f) {
    const uuid = uuidv4();
    const input = `./molecules/${f}`;
    const output = `./../client/assets/molecules/${uuid}.svg`;
    fs.readFile(input, 'utf8', (err, sdf) => {
        renderer.renderSdfToSvg(sdf, {}, function(err, svg) {
            if (err) console.error(input, err);
            fs.writeFile(output, svg, 'utf8', err => {
                if (err) console.error(err);
            });
        });
    });
}

