<commit_before>import * as less from "less";

import * as fs from "fs";
import * as path from "path";

const lessPluginCleanCSS = require("less-plugin-clean-css");

export namespace ThemeCompiler {
    const themeRoot: string = path.join(__dirname, "app", "style", "theme");
    const compiledThemeRoot: string = path.join(__dirname, "app", "style", "css");
    const themesFilenames = [];

    export function loadThemes() {
        return new Promise((resolve, reject) => {
            fs.readdirSync(themeRoot).filter(elemName => {
                return !fs.lstatSync(path.join(themeRoot, elemName)).isDirectory();
            }).forEach(elemName => {
                themesFilenames[themesFilenames.length] = elemName;
            });
            resolve();
        });
    }

    function compileTheme(filename: string) {
        return new Promise((resolve, reject) => {
            (less.render(fs.readFileSync(path.join(themeRoot, filename)).toString("utf-8"), {
                plugins: [new lessPluginCleanCSS({ advanced: true })],
                paths:  [path.join(__dirname, "app", "style")]
            } as any) as any).then(output => {
                fs.writeFile(path.join(compiledThemeRoot, filename.replace("less", "css")), output.css, err => {
                    if (err) return reject(err);
                    resolve();
                });
            }).catch(reject);
        });
    }

    export function compileThemes() {
        return new Promise((resolve, reject) => {
            Promise.all(themesFilenames.map(filename => compileTheme(filename)))
                .then(resolve)
                .catch(reject);
        });
    }
}<commit_msg>Attach log<commit_after>import * as less from "less";

import * as fs from "fs";
import * as path from "path";

const lessPluginCleanCSS = require("less-plugin-clean-css");

export namespace ThemeCompiler {
    const themeRoot: string = path.join(__dirname, "app", "style", "theme");
    const compiledThemeRoot: string = path.join(__dirname, "app", "style", "css");
    const themesFilenames = [];

    export function loadThemes() {
        return new Promise((resolve, reject) => {
            console.log("THEME ROOT : ", themeRoot);
            fs.readdirSync(themeRoot).filter(elemName => {
                console.log("WARN DIR : ", path.join(themeRoot, elemName));
                return !fs.lstatSync(path.join(themeRoot, elemName)).isDirectory();
            }).forEach(elemName => {
                themesFilenames[themesFilenames.length] = elemName;
            });
            resolve();
        });
    }

    function compileTheme(filename: string) {
        return new Promise((resolve, reject) => {
            console.log("READ TO COMPILE : ", path.join(themeRoot, filename));
            console.log("LESS ROOT : ", path.join(__dirname, "app", "style"));
            (less.render(fs.readFileSync(path.join(themeRoot, filename)).toString("utf-8"), {
                plugins: [new lessPluginCleanCSS({ advanced: true })],
                paths:  [path.join(__dirname, "app", "style")]
            } as any) as any).then(output => {
                console.log("WRITE LESS : ", path.join(compiledThemeRoot, filename.replace("less", "css")));
                fs.writeFile(path.join(compiledThemeRoot, filename.replace("less", "css")), output.css, err => {
                    if (err) return reject(err);
                    resolve();
                });
            }).catch(reject);
        });
    }

    export function compileThemes() {
        return new Promise((resolve, reject) => {
            Promise.all(themesFilenames.map(filename => compileTheme(filename)))
                .then(resolve)
                .catch(reject);
        });
    }
}
{'fraction_non_alphanumeric': 0.1475060016004268, 'fraction_numerical': 0.0005334755934915977, 'mean_word_length': 2.2665505226480835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5178591', 'n_tokens_mistral': 1033, 'n_tokens_neox': 998, 'n_words': 215}