<commit_before>const fs = require('fs');
const glob = require("glob");

const babel = require("babel-core");
const uglifyJS = require("uglify-js");
const ncp = require("ncp");
const chokidar = require("chokidar");
const stylus = require("stylus");
const stylus_autoprefixer = require("autoprefixer-stylus");

const eslint = new (require("eslint").CLIEngine)();
const lintFormatter = eslint.getFormatter();

const livereload = require("livereload");
const server = require("http-server");
const opn = require("opn");

const paths = {
    script: "./src/flatpickr.js",
    themes: "./src/style/themes/*.styl",
    style: "./src/style/flatpickr.styl",
    plugins: "./src/plugins",
    l10n: "./src/l10n"
}

function logErr(e){
    console.error(e);
}

function lint(code, filename){
    const report = eslint.executeOnText(code, filename);
    if (report.errorCount || report.warningCount)
        process.stdout.write(
            lintFormatter(report.results)
        );

    else
        console.info("Linting: OK ✓")
}

async function recursiveCopy(src, dest) {
    return new Promise((resolve, reject) => {
        ncp(src, dest, err => {
            if (!err)
                resolve();
            else
                reject();
        });
    })
}

async function readFileAsync(path) {
    return new Promise((resolve, reject) => {
        fs.readFile(path, (err, buffer) => {
            if (err)
                reject(err);
            else
                resolve(buffer.toString());
        })
    })
}

async function writeFileAsync(path, content) {
    return new Promise((resolve, reject) => {
        fs.writeFile(path, content, (err, ok) => {
            if (err)
                reject(err);
            else
                resolve();
        })
    })
}

function transpile(src){
    return babel.transform(src, {
        "presets": [ "es2015" ],
        "plugins": ["transform-remove-strict-mode", "transform-object-assign"]
    }).code;
}

function uglify(src) {
    return uglifyJS.minify(src, {
        fromString: true,
        output: {
            comments: /license/
        }
    }).code;
}

async function buildScripts(){
    const src = await readFileAsync(paths.script).catch(logErr);
    lint(src, paths.script);
    const transpiled = transpile(src);

    writeFileAsync("./dist/flatpickr.js", transpiled).catch(logErr);
    writeFileAsync("./dist/flatpickr.min.js", uglify(transpiled)).catch(logErr);
}

function resolveGlob(g) {
    return new Promise((resolve, reject) => {
        glob(g, (err, files) =>{
            if (err)
                reject(err);

            else
                resolve(files);
        });
    });
}<commit_msg>Build - rm deprecated uglifyjs option<commit_after>const fs = require('fs');
const glob = require("glob");

const babel = require("babel-core");
const uglifyJS = require("uglify-js");
const ncp = require("ncp");
const chokidar = require("chokidar");
const stylus = require("stylus");
const stylus_autoprefixer = require("autoprefixer-stylus");

const eslint = new (require("eslint").CLIEngine)();
const lintFormatter = eslint.getFormatter();

const livereload = require("livereload");
const server = require("http-server");
const opn = require("opn");

const paths = {
    script: "./src/flatpickr.js",
    themes: "./src/style/themes/*.styl",
    style: "./src/style/flatpickr.styl",
    plugins: "./src/plugins",
    l10n: "./src/l10n"
}

function logErr(e){
    console.error(e);
}

function lint(code, filename){
    const report = eslint.executeOnText(code, filename);
    if (report.errorCount || report.warningCount)
        process.stdout.write(
            lintFormatter(report.results)
        );

    else
        console.info("Linting: OK ✓")
}

async function recursiveCopy(src, dest) {
    return new Promise((resolve, reject) => {
        ncp(src, dest, err => {
            if (!err)
                resolve();
            else
                reject();
        });
    })
}

async function readFileAsync(path) {
    return new Promise((resolve, reject) => {
        fs.readFile(path, (err, buffer) => {
            if (err)
                reject(err);
            else
                resolve(buffer.toString());
        })
    })
}

async function writeFileAsync(path, content) {
    return new Promise((resolve, reject) => {
        fs.writeFile(path, content, (err, ok) => {
            if (err)
                reject(err);
            else
                resolve();
        })
    })
}

function transpile(src){
    return babel.transform(src, {
        "presets": [ "es2015" ],
        "plugins": ["transform-remove-strict-mode", "transform-object-assign"]
    }).code;
}

function uglify(src) {
    const minified = uglifyJS.minify(src, {
        output: {
            comments: /license/
        }
    });

    if (!minified.error)
        return minified.code;
    
    console.error(minified.error);
    return "";    
}

async function buildScripts(){
    const src = await readFileAsync(paths.script).catch(logErr);
    lint(src, paths.script);
    const transpiled = transpile(src);

    writeFileAsync("./dist/flatpickr.js", transpiled).catch(logErr);
    writeFileAsync("./dist/flatpickr.min.js", uglify(transpiled)).catch(logErr);
}

function resolveGlob(g) {
    return new Promise((resolve, reject) => {
        glob(g, (err, files) =>{
            if (err)
                reject(err);

            else
                resolve(files);
        });
    });
}
{'fraction_non_alphanumeric': 0.15296052631578946, 'fraction_numerical': 0.0029239766081871343, 'mean_word_length': 2.3763109191856877, 'pattern_counts': {'":': 4, '<': 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': '1228527', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1678, 'n_words': 346}