<commit_before>var Promise = require('bluebird'),
    logger = require('./logger'),
    fs = require('fs'),
    path = require('path'),
    semver = require('semver');

var exec = Promise.promisify(require('child_process').exec);

var versionChecks = [{
    name: 'node',
    cmd: 'node -v',
    versions: '0.10.40'
},
{
    name: 'python',
    cmd: 'python ' + path.join(__dirname, '../version.py'), // for some reason, python --version doesn't return on stdout
    versions: '2.7.x'
},
{
    name: 'meteor',
    cmd: 'meteor --version',
    versions: '>0.8.1 || 1.x'
}]

module.exports = {
    run: function(options){
        logger.level = 'silly';
        return new Promise(function(resolve, reject){
            Promise.all(versionChecks.map(function(check){
                return validateVersion(check.name, check.cmd, check.versions);
            }))
            .catch(reject)
            .then(checkForVCR)
            .catch(reject)
            .then(resolve);
        });
    }
}

var validateVersion = function(name, cmd, versions) {
    return new Promise(function(resolve, reject) {
        exec(cmd)
        .catch(reject)
        .then(function(result){
            logger.silly(cmd + ' -> stdout: ' + result);
            var matches = result.match(/(\d+\.\d+\.\d+)/g);
            var curr = matches ? matches[0] : null;
            if(curr && semver.satisfies(curr, versions)){
                logger.verbose('run-precheck', name + ' has a valid version. Current version: ' + curr + ' Valid version(s): ' + versions);
                resolve();
            } else {
                reject(name + ' has an invalid version. Current version: ' + curr + ' Valid version(s): ' + versions);
            }
        })
        .then(resolve, reject);
    })<commit_msg>Updated run-precheck.js validateVersion to check for MAJOR.MINOR version. This ensures that Meteor 1.3 validates correctly as it doesn't follow semver specifications and only returns MAJOR.MINOR (1.3) instead of MAJOR.MINOR.PATCH (1.3.0).<commit_after>var Promise = require('bluebird'),
    logger = require('./logger'),
    fs = require('fs'),
    path = require('path'),
    semver = require('semver');

var exec = Promise.promisify(require('child_process').exec);

var versionChecks = [{
    name: 'node',
    cmd: 'node -v',
    versions: '0.10.40'
},
{
    name: 'python',
    cmd: 'python ' + path.join(__dirname, '../version.py'), // for some reason, python --version doesn't return on stdout
    versions: '2.7.x'
},
{
    name: 'meteor',
    cmd: 'meteor --version',
    versions: '>0.8.1 || 1.x'
}]

module.exports = {
    run: function(options){
        logger.level = 'silly';
        return new Promise(function(resolve, reject){
            Promise.all(versionChecks.map(function(check){
                return validateVersion(check.name, check.cmd, check.versions);
            }))
            .catch(reject)
            .then(checkForVCR)
            .catch(reject)
            .then(resolve);
        });
    }
}

var validateVersion = function(name, cmd, versions) {
    return new Promise(function(resolve, reject) {
        exec(cmd)
        .catch(reject)
        .then(function(result){
            logger.silly(cmd + ' -> stdout: ' + result);
            var matches = result.match(/(\d+\.\d+\.\d+)/g);
            var curr = matches ? matches[0] : null;

            // Meteor 1.3 returns "Meteor 1.3" without a PATCH revision. This isn't semver compliant, so we need
            // to cater for MAJOR.MINOR. If found, append .0 to make it MAJOR.MINOR.PATCH so that semver works.
            if (matches == null) {
                matches = result.match(/(\d+\.\d+)/g);
                curr = matches ? matches[0] + '.0' : null;
            }

            if(curr && semver.satisfies(curr, versions)){
                logger.verbose('run-precheck', name + ' has a valid version. Current version: ' + curr + ' Valid version(s): ' + versions);
                resolve();
            } else {
                reject(name + ' has an invalid version. Current version: ' + curr + ' Valid version(s): ' + versions);
            }
        })
        .then(resolve, reject);
    })
{'fraction_non_alphanumeric': 0.15465645199904238, 'fraction_numerical': 0.009097438352884846, 'mean_word_length': 2.1063197026022307, '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': '3055904', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1239, 'n_words': 309}