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

"use strict";

var Liftoff = require('liftoff');

var Patata = new Liftoff({
  name: 'patata',
  processTitle: 'patata',
  moduleName: 'patata',
  configName: 'patatafile'
});

Patata.launch({}, function(result) {
    var argv = require('yargs').argv;
    if (argv._.length === 0) {
        throw "No suites launched. Please use: patata [suite]";
    }
    
    // Require patatafile
    require(result.configPath);
    var patata = require(result.modulePath);
    
    // Init suite
    patata.init(argv._[0]);

    // Init cucumber
    var Cucumber = require(process.cwd() + '/node_modules/cucumber/lib/cucumber');
    var supportDir = process.cwd() + '/node_modules/patata/dist/js/cucumber/support/';
    var featuresDir = process.cwd() + '/features/';
    var cli = Cucumber.Cli(['','',"--require", supportDir, "--require", featuresDir, featuresDir]);
    cli.run(function (succeeded) {
    var code = succeeded ? 0 : 1;

    function exitNow() {
        process.exit(code);
    }

    if (process.stdout.write('')) {
        exitNow();
    } else {
        // write() returned false, kernel buffer is not empty yet...
        process.stdout.on('drain', exitNow);
    }
    });

});<commit_msg>Use feature folders<commit_after>#!/usr/bin/env node

"use strict";

var Liftoff = require('liftoff');

var Patata = new Liftoff({
  name: 'patata',
  processTitle: 'patata',
  moduleName: 'patata',
  configName: 'patatafile'
});

Patata.launch({}, function(result) {
    var argv = require('yargs').argv;
    if (argv._.length === 0) {
        throw "No suites launched. Please use: patata [suite]";
    }
    
    // Require patatafile
    require(result.configPath);
    var patata = require(result.modulePath);
    
    // Init suite
    patata.init(argv._[0]);
    
    patata.currentSuite.features = 
        patata.currentSuite.features && patata.currentSuite.features.length ? 
        patata.currentSuite.features :
        [ 'features' ];
    
    // Init cucumber
    var Cucumber = require(process.cwd() + '/node_modules/cucumber/lib/cucumber');
    var supportDir = process.cwd() + '/node_modules/patata/dist/js/cucumber/support/';
    
    var defaultArgs = ['','', '--require', supportDir];
    var featureRequireArgs = buildFeatureArgs(patata.currentSuite, true);    
    var featureArgs = buildFeatureArgs(patata.currentSuite);    

    var args = defaultArgs.concat(featureRequireArgs);
    args = args.concat(featureArgs);
    
    console.log(args);
    
    var cli = Cucumber.Cli(args);
    cli.run(function (succeeded) {
    var code = succeeded ? 0 : 1;

    function exitNow() {
        process.exit(code);
    }

    if (process.stdout.write('')) {
        exitNow();
    } else {
        // write() returned false, kernel buffer is not empty yet...
        process.stdout.on('drain', exitNow);
    }
    });

});

function buildFeatureArgs(suite, useRequire) {
    var result = [];
    
    for (var i = 0; i < suite.features.length; i++) {
        if (useRequire) {
            result.push('--require');
        }
        result.push(process.cwd() + '/' + suite.features[i]);
    }
    
    return result;
}
{'fraction_non_alphanumeric': 0.1565162511833386, 'fraction_numerical': 0.002840012622278321, 'mean_word_length': 2.6647398843930636, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2662706', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1017, 'n_words': 215}