<commit_before>const RemixTests = require('remix-tests');
const Solc = require('solc');

function _testCallback(result) {
    try {
        process.send({ _testCallback: '_testCallback', result });
    } catch (e) {
        process.send({ error: e });
    }
}
function _resultsCallback(e, result) {
    if(e) {
        process.send({ error: e });
    }
    process.send({ _resultsCallback: '_resultsCallback', result });
}
function _finalCallback(e, result) {
    if(e) {
        process.send({ error: e });
    }
    process.send({ _finalCallback: '_finalCallback', result });
    process.exit(0);
}
function _importFileCb(e, result) {
    if(e) {
        process.send({ error: e });
    }
}

process.on('message', async(m) => {
    if (m.command === 'compile') {
        try {
            const input = m.payload;
            const installedSlocVersion = 'v'+Solc.version();
            const requiredSolcVersion = m.version;

            if(installedSlocVersion.includes(requiredSolcVersion)) {
                const output = await Solc.compileStandardWrapper(JSON.stringify(input));
                process.send({ compiled: output });
            } else {
                Solc.loadRemoteVersion(requiredSolcVersion, async(err, solcSnapshot) => {
                    if (err) {
                        process.send({ error: err });
                    } else {
                        const output = await solcSnapshot.compile(JSON.stringify(input));
                        process.send({ compiled: output });
                    }
                });
            }
        } catch (e) {
            throw e;
        }
    }
    if (m.command === 'runTests') {
        try {
            const sources = m.payload;
            RemixTests.runTestSources(sources, _testCallback, _resultsCallback, _finalCallback, _importFileCb);
        } catch (e) {
            throw e;
        }
    }
});
module.exports = {};<commit_msg>add todo for store sloc version in redux<commit_after>const RemixTests = require('remix-tests');
const Solc = require('solc');

function _testCallback(result) {
    try {
        process.send({ _testCallback: '_testCallback', result });
    } catch (e) {
        process.send({ error: e });
    }
}
function _resultsCallback(e, result) {
    if(e) {
        process.send({ error: e });
    }
    process.send({ _resultsCallback: '_resultsCallback', result });
}
function _finalCallback(e, result) {
    if(e) {
        process.send({ error: e });
    }
    process.send({ _finalCallback: '_finalCallback', result });
    process.exit(0);
}
function _importFileCb(e, result) {
    if(e) {
        process.send({ error: e });
    }
}

process.on('message', async(m) => {
    if (m.command === 'compile') {
        try {
            const input = m.payload;
            const installedSlocVersion = 'v'+Solc.version();
            const requiredSolcVersion = m.version;

            if(installedSlocVersion.includes(requiredSolcVersion)) {
                const output = await Solc.compileStandardWrapper(JSON.stringify(input));
                process.send({ compiled: output });
            } else {
                
                /**
                 * TODO Store cached versions in redux
                 * For one cached version store vesrion and snapshot
                 */

                Solc.loadRemoteVersion(requiredSolcVersion, async(err, solcSnapshot) => {
                    if (err) {
                        process.send({ error: err });
                    } else {
                        const output = await solcSnapshot.compile(JSON.stringify(input));
                        process.send({ compiled: output });
                    }
                });
            }
        } catch (e) {
            throw e;
        }
    }
    if (m.command === 'runTests') {
        try {
            const sources = m.payload;
            RemixTests.runTestSources(sources, _testCallback, _resultsCallback, _finalCallback, _importFileCb);
        } catch (e) {
            throw e;
        }
    }
});
module.exports = {};
{'fraction_non_alphanumeric': 0.1278640059127864, 'fraction_numerical': 0.0004927322000492732, 'mean_word_length': 1.786547700754976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2532256', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1094, 'n_words': 239}