{"size": 821, "ext": "js", "max_stars_repo_path": "util/sassRender.js", "max_stars_repo_name": "karllabrador/aprilon", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "util/sassRender.js", "max_issues_repo_name": "karllabrador/aprilon", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "util/sassRender.js", "max_forks_repo_name": "karllabrador/aprilon", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.4571428571, "max_line_length": 75, "alphanum_fraction": 0.5054811206}
const fs = require('fs');
const sass = require('sass');

/**
 * Simple wrapper for sass
 * @param file
 * @param outputFile
 */
const sassRender = (file, outputFile) => {
    const outputDir = outputFile.substring(0, outputFile.lastIndexOf('/'));
    fs.mkdir(outputDir, { recursive: true }, e => {
        if (e) return console.error(e);

        console.info('Created directory %s', outputDir);
    });

    sass.render(
        {
            file: file,
            outputStyle: 'compressed',
        },
        (error, result) => {
            if (!error) {
                fs.writeFile(outputFile, result.css, e => {
                    if (e) return console.error(e);

                    console.info('Wrote to %s', outputFile);
                });
            }
        },
    );
};

module.exports = sassRender;
