<commit_before>var expect = require('../unexpected-with-plugins');
var pathModule = require('path');
var Promise = require('bluebird');
var rimrafAsync = Promise.promisify(require('rimraf'));
var fs = Promise.promisifyAll(require('fs'));
var getTemporaryFilePath = require('gettemporaryfilepath');
var childProcess = Promise.promisifyAll(require('child_process'), {multiArgs: true});

function run(commandAndArgs) {
    if (typeof commandAndArgs !== 'undefined' && !Array.isArray(commandAndArgs)) {
        commandAndArgs = [ commandAndArgs ];
    }
    var command = commandAndArgs.map(function (arg) {
        return /[^\w./-]/.test(arg) ? '\'' + arg.replace(/'/g, '\\\'') + '\'' : arg;
    }).join(' ');
    return Promise.fromNode(function (cb) {
        childProcess.exec(command, cb);
    }, { multiArgs: true });
}

expect.addAssertion('<string|array> [when] run as a shell command <assertion?>', function (expect, subject) {
    return run(subject).then(function (stdout) {
        return expect.shift(stdout);
    });
});

describe('buildProduction', function () {
    it('should honor --browsers "IE 8" when serializing Javascript', function () {
        var tmpDir = getTemporaryFilePath();
        return expect([
            pathModule.resolve(__dirname, '..', '..', 'bin', 'buildProduction'),
            '--root', pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8'),
            '--outroot', tmpDir,
            '--browsers', 'IE 8',
            pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8', 'index.html')
        ], 'run as a shell command').then(function (stdout) {
            return fs.readFileAsync(pathModule.resolve(tmpDir, 'index.html'), 'utf-8');
        }).then(function (builtIndexHtml) {
            expect(builtIndexHtml, 'to contain', 'foo["catch"]=123');
        }).finally(function () {
            return rimrafAsync(tmpDir);
        });
    });

    it('should assume that IE 8 compatibility is wanted when no --browsers switch is passed', function () {
        var tmpDir = getTemporaryFilePath();
        return expect([
            pathModule.resolve(__dirname, '..', '..', 'bin', 'buildProduction'),
            '--root', pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8'),
            '--outroot', tmpDir,
            pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8', 'index.html')
        ], 'run as a shell command').then(function (stdout) {
            return fs.readFileAsync(pathModule.resolve(tmpDir, 'index.html'), 'utf-8');
        }).then(function (builtIndexHtml) {
            expect(builtIndexHtml, 'to contain', 'foo["catch"]=123');
        }).finally(function () {
            return rimrafAsync(tmpDir);
        });
    });
});
<commit_msg>Expect singlequotes<commit_after>var expect = require('../unexpected-with-plugins');
var pathModule = require('path');
var Promise = require('bluebird');
var rimrafAsync = Promise.promisify(require('rimraf'));
var fs = Promise.promisifyAll(require('fs'));
var getTemporaryFilePath = require('gettemporaryfilepath');
var childProcess = Promise.promisifyAll(require('child_process'), {multiArgs: true});

function run(commandAndArgs) {
    if (typeof commandAndArgs !== 'undefined' && !Array.isArray(commandAndArgs)) {
        commandAndArgs = [ commandAndArgs ];
    }
    var command = commandAndArgs.map(function (arg) {
        return /[^\w./-]/.test(arg) ? '\'' + arg.replace(/'/g, '\\\'') + '\'' : arg;
    }).join(' ');
    return Promise.fromNode(function (cb) {
        childProcess.exec(command, cb);
    }, { multiArgs: true });
}

expect.addAssertion('<string|array> [when] run as a shell command <assertion?>', function (expect, subject) {
    return run(subject).then(function (stdout) {
        return expect.shift(stdout);
    });
});

describe('buildProduction', function () {
    it('should honor --browsers "IE 8" when serializing Javascript', function () {
        var tmpDir = getTemporaryFilePath();
        return expect([
            pathModule.resolve(__dirname, '..', '..', 'bin', 'buildProduction'),
            '--root', pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8'),
            '--outroot', tmpDir,
            '--browsers', 'IE 8',
            pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8', 'index.html')
        ], 'run as a shell command').then(function (stdout) {
            return fs.readFileAsync(pathModule.resolve(tmpDir, 'index.html'), 'utf-8');
        }).then(function (builtIndexHtml) {
            expect(builtIndexHtml, 'to contain', "foo['catch']=123");
        }).finally(function () {
            return rimrafAsync(tmpDir);
        });
    });

    it('should assume that IE 8 compatibility is wanted when no --browsers switch is passed', function () {
        var tmpDir = getTemporaryFilePath();
        return expect([
            pathModule.resolve(__dirname, '..', '..', 'bin', 'buildProduction'),
            '--root', pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8'),
            '--outroot', tmpDir,
            pathModule.resolve(__dirname, '..', '..', 'testdata', 'bin', 'buildProduction', 'javaScriptWithInternetExplorer8', 'index.html')
        ], 'run as a shell command').then(function (stdout) {
            return fs.readFileAsync(pathModule.resolve(tmpDir, 'index.html'), 'utf-8');
        }).then(function (builtIndexHtml) {
            expect(builtIndexHtml, 'to contain', "foo['catch']=123");
        }).finally(function () {
            return rimrafAsync(tmpDir);
        });
    });
});

{'fraction_non_alphanumeric': 0.18092661481230976, 'fraction_numerical': 0.005072708826513358, 'mean_word_length': 3.2492816091954024, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7362703', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1687, 'n_words': 351}