<commit_before>'use strict';

const childProcess = require('child_process');
const fs = require('fs');

module.exports = function(type) {
    process.argv.shift();
    process.argv.shift();
    var path = process.argv.length < 1 ? 'output_data' : process.argv[0];

    var process_generate = childProcess.spawn('./node_modules/podigg/bin/generate-' + type + '.js', process.argv);
    process_generate.stdout.pipe(process.stdout);
    process_generate.stderr.pipe(process.stderr);
    process_generate.on('close', (code_generate) => {
        if(!code_generate) {
            var process_convert = childProcess.spawn('./node_modules/gtfs2lc/bin/gtfs2lc.js', [path + '/gtfs', '-f', 'turtle', '-r', '-t', '-a']);
            process_convert.stdout.pipe(fs.createWriteStream(path + '/lc.ttl'));
            process_convert.stderr.pipe(process.stderr);
            process_convert.on('close', (code_convert) => {
                if (code_generate) {
                    throw new Error('Conversion exited with exit code ' + code_convert);
                }
            });
        } else {
            throw new Error('Generation exited with exit code ' + code_generate);
        }
    });
}<commit_msg>Fix external script invocation failing with ENOENT error<commit_after>'use strict';

const childProcess = require('child_process');
const fs = require('fs');

module.exports = function(type) {
    process.argv.shift();
    process.argv.shift();
    var path = process.argv.length < 1 ? 'output_data' : process.argv[0];

    var process_generate = childProcess.spawn(__dirname + '/../node_modules/podigg/bin/generate-' + type + '.js', process.argv);
    process_generate.stdout.pipe(process.stdout);
    process_generate.stderr.pipe(process.stderr);
    process_generate.on('close', (code_generate) => {
        if(!code_generate) {
            var process_convert = childProcess.spawn(__dirname + '/../node_modules/gtfs2lc/bin/gtfs2lc.js', [path + '/gtfs', '-f', 'turtle', '-r', '-t', '-a']);
            process_convert.stdout.pipe(fs.createWriteStream(path + '/lc.ttl'));
            process_convert.stderr.pipe(process.stderr);
            process_convert.on('close', (code_convert) => {
                if (code_generate) {
                    throw new Error('Conversion exited with exit code ' + code_convert);
                }
            });
        } else {
            throw new Error('Generation exited with exit code ' + code_generate);
        }
    });
}
{'fraction_non_alphanumeric': 0.15241183623834617, 'fraction_numerical': 0.0032428050263477908, 'mean_word_length': 2.7507598784194527, 'pattern_counts': {'":': 0, '<': 5, '<?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': '296653', 'n_tokens_mistral': 723, 'n_tokens_neox': 702, 'n_words': 135}