{"size": 1026, "ext": "js", "max_stars_repo_path": "src/build.js", "max_stars_repo_name": "Gusted/COVID-Simulation", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/build.js", "max_issues_repo_name": "Gusted/COVID-Simulation", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/build.js", "max_forks_repo_name": "Gusted/COVID-Simulation", "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": 24.4285714286, "max_line_length": 123, "alphanum_fraction": 0.5360623782}
const {execFile} = require('child_process');
const {build} = require('esbuild');

async function typeCheck() {
    await new Promise((resolve, reject) => {
        execFile(process.execPath, [require.resolve('typescript/lib/tsc.js'), '--project', 'src/tsconfig.json'], (err) => {
            if (err) {
                reject(new Error(`tsc has exited with error: ${err.message}`));
            } else {
                resolve();
            }
        });
    });
}



async function bundleJS(release) {
    await build({
        bundle: true,
        target: 'es2019',
        charset: 'utf8',
        format: 'iife',
        write: true,
        outfile: 'simulatie.js',
        entryPoints: ['src/simulatie.ts'],
        banner: '"use strict";',
        logLevel: 'info',
        color: true,
        sourcemap: release ? false : 'inline',
        minify: release,
    });
}

async function main() {
    const args = process.argv.slice(2);
    await typeCheck();
    await bundleJS(args.includes('--release'));
}

main();
