<commit_before>var buildDir = 'build';

var path = require('path');
var UglifyJS = require("uglify-js");
var fs = require('fs');
var cli = require('commander');
var wrench = require('wrench');
var glob = require('glob-whatev')


cli
    .version('0.1.0')
    .option('--pretty', 'Skip uglification and just concatenate the files for debugging.')

cli
    .command('build')
    .description('concatenate (and uglify unless using --pretty) files and place them in the build directory')
    .action(build)

cli
    .command('clean')
    .description('erase the build directory and its contents')
    .action(clean)



function build() {
    clean();
    console.log('building all...');
    gluJS();
    gluJSTest();
    gluJSExt3();
    gluJSExt4();
    copyToBuild('MIT.LICENSE');
    copyToBuild('readme.txt');
    copyExamples();
}

function clean() {
    if (path.existsSync(buildDir)) {
        wrench.rmdirSyncRecursive('build');
        console.log('deleted old build.');
    } else {
        console.log('no old build to clean.');
    }
}

function copyExamples() {
    console.log('copying examples');
    copyDirs('examples', buildDir + '/examples', function(kind, dir, filename, contents){
        if (filename.match(/^\./)) return false;
        if (kind==='f' && (filename==='index.html' || filename==='runner.html')) {
            return contents.replace(/\.\.\/\.\.\/build\/glu/g,'../../glu');
        }
    });
    wrench.mkdirSyncRecursive(buildDir + '/lib/extjs-4.x');
}

function gluJS() {
    console.log('building Core');
    var files = new FileList()
        .include('src/glu.js')
        .include('src/conventions.js')
        .include('src/viewmodel.js')
        .include('src/list.js')
        .include('src/*.js');
    concat('build/glu.js', files);
}

function gluJSTest() {
    console.log('building test library');
    var files = new FileList()
        .include('src/test/*.js');
    concat('build/glu-test.js', files);
}

function gluJSExt3() {
    console.log('building Ext JS 3.x adapter');
    var files = new FileList()
        .include('src/providers/sencha/setup.js')
        .include('src/providers/sencha/*.js')
        .include('src/providers/sencha/adapters_extjs/basic.js')
        .include('src/providers/sencha/adapters_extjs/*.js')
        .include('src/providers/sencha/adapters_extjs3/*.js')
    concat('build/glu-extjs-3.js', files);
}

function gluJSExt4() {
    console.log('building Ext JS 4.x adapter');
    var files = new FileList()
        .include('src/providers/sencha/setup.js')
        .include('src/providers/sencha/*.js')
        .include('src/providers/sencha/adapters_extjs/basic.js')
        .include('src/providers/sencha/adapters_extjs/*.js')
        .include('src/providers/sencha/adapters_extjs4/*.js')
    concat('build/glu-extjs-4.js', files);
}

//MINI-BUILD LIBRARY
var license = "// Copyright (c) 2012 CoNarrative - http://www.conarrative.com/\n" +
    "// License: MIT (http://www.opensource.org/licenses/mit-license.php)\n" +
    "// GluJS version 1.1.0\n";
function concat(combined, files) {
    //make parent directory of combined output file
    var lastSlashIdx = combined.lastIndexOf('/');
    if (lastSlashIdx == -1) {<commit_msg>Fixed node existsSync and library licence version<commit_after>var buildDir = 'build';

var path = require('path');
var UglifyJS = require("uglify-js");
var fs = require('fs');
var cli = require('commander');
var wrench = require('wrench');
var glob = require('glob-whatev')


cli
    .version('0.1.0')
    .option('--pretty', 'Skip uglification and just concatenate the files for debugging.')

cli
    .command('build')
    .description('concatenate (and uglify unless using --pretty) files and place them in the build directory')
    .action(build)

cli
    .command('clean')
    .description('erase the build directory and its contents')
    .action(clean)



function build() {
    clean();
    console.log('building all...');
    gluJS();
    gluJSTest();
    gluJSExt3();
    gluJSExt4();
    copyToBuild('MIT.LICENSE');
    copyToBuild('readme.txt');
    copyExamples();
}

function clean() {
    if (fs.existsSync(buildDir)) {
        wrench.rmdirSyncRecursive('build');
        console.log('deleted old build.');
    } else {
        console.log('no old build to clean.');
    }
}

function copyExamples() {
    console.log('copying examples');
    copyDirs('examples', buildDir + '/examples', function(kind, dir, filename, contents){
        if (filename.match(/^\./)) return false;
        if (kind==='f' && (filename==='index.html' || filename==='runner.html')) {
            return contents.replace(/\.\.\/\.\.\/build\/glu/g,'../../glu');
        }
    });
    wrench.mkdirSyncRecursive(buildDir + '/lib/extjs-4.x');
}

function gluJS() {
    console.log('building Core');
    var files = new FileList()
        .include('src/glu.js')
        .include('src/conventions.js')
        .include('src/viewmodel.js')
        .include('src/list.js')
        .include('src/*.js');
    concat('build/glu.js', files);
}

function gluJSTest() {
    console.log('building test library');
    var files = new FileList()
        .include('src/test/*.js');
    concat('build/glu-test.js', files);
}

function gluJSExt3() {
    console.log('building Ext JS 3.x adapter');
    var files = new FileList()
        .include('src/providers/sencha/setup.js')
        .include('src/providers/sencha/*.js')
        .include('src/providers/sencha/adapters_extjs/basic.js')
        .include('src/providers/sencha/adapters_extjs/*.js')
        .include('src/providers/sencha/adapters_extjs3/*.js')
    concat('build/glu-extjs-3.js', files);
}

function gluJSExt4() {
    console.log('building Ext JS 4.x adapter');
    var files = new FileList()
        .include('src/providers/sencha/setup.js')
        .include('src/providers/sencha/*.js')
        .include('src/providers/sencha/adapters_extjs/basic.js')
        .include('src/providers/sencha/adapters_extjs/*.js')
        .include('src/providers/sencha/adapters_extjs4/*.js')
    concat('build/glu-extjs-4.js', files);
}

//MINI-BUILD LIBRARY
var license = "// Copyright (c) 2012 CoNarrative - http://www.conarrative.com/\n" +
    "// License: MIT (http://www.opensource.org/licenses/mit-license.php)\n" +
    "// GluJS version 1.1.0 (maybe it is actually 1.2.0?)\n" +
    "// Build by <NAME> from Ryan Smith fork\n";
function concat(combined, files) {
    //make parent directory of combined output file
    var lastSlashIdx = combined.lastIndexOf('/');
    if (lastSlashIdx == -1) {
{'fraction_non_alphanumeric': 0.17921640648913376, 'fraction_numerical': 0.007193143556779921, 'mean_word_length': 2.9654126213592233, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5019842', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2177, 'n_words': 424}