<commit_before>#!/usr/bin/env node

//TODO Fix arguments, allow for specifiying browsers in any order
//TODO add port option for zwitterion to arguments
//TODO allow the entry file to be anywhere in the arguments
//TODO allow for passing in custom arguments for each browser
//TODO firefox-nightly doesn't ever open, probably because of the -
//TODO allow for automated testing in ci environments...use karma, probably

const path = require('path');
const child_process = require('child_process');
const karma = require('karma');

(async () => {

    const zwitterionPort = 5001;

    //TODO decide if arbitrary ports are better or if one port is better, passed in by the user. One port for all browsers are individual ports for each browser
    await loadZwitterion(zwitterionPort);

    const userFileInput = process.argv[2];

    let guessworkPlugin = function(files) {
        files.unshift({
            pattern: path.join(process.cwd(), userFileInput),
            included: true,
            served: true,
            watched: true,
            // type: 'module'
        });
    };

    guessworkPlugin.$inject = ['config.files'];

    const karmaServer = new karma.Server({
        proxies: {
            '/base/': `http://localhost:${zwitterionPort}/`
        },
        port: zwitterionPort - 1,
        plugins: [{
            'framework:guesswork': ['factory', guessworkPlugin]
        },
        'karma-chrome-launcher',
        'karma-firefox-launcher'],
        frameworks: ['guesswork'],
        // client: {
        //     runInParent: true,
        //     // useIframe: false
        // }
        singleRun: true,
        browsers: ['ChromiumHeadless', 'FirefoxHeadless'],
        // files: [<commit_msg>load the initial script as a module, add firefoxheadless flag for modules until the next release<commit_after>#!/usr/bin/env node

//TODO Fix arguments, allow for specifiying browsers in any order
//TODO add port option for zwitterion to arguments
//TODO allow the entry file to be anywhere in the arguments
//TODO allow for passing in custom arguments for each browser
//TODO firefox-nightly doesn't ever open, probably because of the -
//TODO allow for automated testing in ci environments...use karma, probably

const path = require('path');
const child_process = require('child_process');
const karma = require('karma');

(async () => {

    const zwitterionPort = 5001;

    //TODO decide if arbitrary ports are better or if one port is better, passed in by the user. One port for all browsers are individual ports for each browser
    await loadZwitterion(zwitterionPort);

    const userFileInput = process.argv[2];

    let guessworkPlugin = function(files) {
        files.unshift({
            pattern: path.join(process.cwd(), userFileInput),
            included: true,
            served: true,
            watched: true,
            type: 'module'
        });
    };

    guessworkPlugin.$inject = ['config.files'];

    const karmaServer = new karma.Server({
        proxies: {
            '/base/': `http://localhost:${zwitterionPort}/`
        },
        port: zwitterionPort - 1,
        plugins: [{
            'framework:guesswork': ['factory', guessworkPlugin]
        },
        'karma-chrome-launcher',
        'karma-firefox-launcher'],
        frameworks: ['guesswork'],
        singleRun: true,
        browsers: ['ChromiumHeadless', 'FirefoxHeadlessWithFlags'],
        customLaunchers: {
            FirefoxHeadlessWithFlags: {
                base: 'FirefoxHeadless',
                prefs: {
                    'dom.moduleScripts.enabled': true //TODO Get rid of this flag once Firefox supports modules (should be the next release, Firefox 60)
                }
            }
        }
        // client: {
        //     runInParent: true,
        //     // useIframe: false
        // }
        // files: [
{'fraction_non_alphanumeric': 0.10722610722610723, 'fraction_numerical': 0.003626003626003626, 'mean_word_length': 2.315021459227468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3456378', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1045, 'n_words': 345}