<commit_before>var fs, processScriptsFileFn, concatJsFiles, scriptsFilePath;

fs = require('fs');
scriptsFilePath = 'scripts.json';

processScriptsFileFn = function (data)
{
    var json;
    
    try
    {
        json = JSON.parse(data);
    }
    catch (e)
    {
        console.log('Parsing file ' + scriptsFilePath + ' as JSON failed!');
        console.log('Error was:' + e);
        
        return;
    }
    
    concatJsFiles(json.files);
};

concatJsFiles = function (fileNames)
{
    var fn, concatFile, len;
    
    concatFile = ''; 
    len = fileNames.length;
    
    fn = function (path, i)
    {
        var concFn;
        
        concFn = function (data)
        {
            concatFile += "\n\n" + data;
        };
        
        concFn(fs.readFileSync('./' + path, 'utf-8'));
    };
    
    fileNames.forEach(fn);
    writeFileFn(concatFile);
};

writeFileFn = function (concatFile)
{
    var errFn;
    
    errFn = function (err)
    {
        if (err)
        {
            console.log(err);
            return;
        }
        
        console.log('WebStory Engine file created.');
    };
    
    fs.writeFile('./releases/current/WebStoryEngine.js', concatFile, errFn);
};

processScriptsFileFn(fs.readFileSync(scriptsFilePath, 'utf-8'));<commit_msg>mkdir is done if needed (because there is no ./releases/current folder in newly forked repo)<commit_after>var fs, mkdirSync, processScriptsFileFn, concatJsFiles, scriptsFilePath;

fs = require('fs');
scriptsFilePath = 'scripts.json';

mkdirSync = function (path)
{
  try
  {
    fs.mkdirSync(path);
  }
  catch(e)
  {
    if ( e.code != 'EEXIST' ) throw e;
  }
}

processScriptsFileFn = function (data)
{
    var json;
    
    try
    {
        json = JSON.parse(data);
    }
    catch (e)
    {
        console.log('Parsing file ' + scriptsFilePath + ' as JSON failed!');
        console.log('Error was:' + e);
        
        return;
    }
    
    concatJsFiles(json.files);
};

concatJsFiles = function (fileNames)
{
    var fn, concatFile, len;
    
    concatFile = ''; 
    len = fileNames.length;
    
    fn = function (path, i)
    {
        var concFn;
        
        concFn = function (data)
        {
            concatFile += "\n\n" + data;
        };
        
        concFn(fs.readFileSync('./' + path, 'utf-8'));
    };
    
    fileNames.forEach(fn);
    writeFileFn(concatFile);
};

writeFileFn = function (concatFile)
{
    var errFn;
    
    errFn = function (err)
    {
        if (err)
        {
            console.log(err);
            return;
        }
        
        console.log('WebStory Engine file created.');
    };
    
    mkdirSync('./releases')
    mkdirSync('./releases/current')
    fs.writeFile('./releases/current/WebStoryEngine.js', concatFile, errFn);
};

processScriptsFileFn(fs.readFileSync(scriptsFilePath, 'utf-8'));
{'fraction_non_alphanumeric': 0.13529617946021733, 'fraction_numerical': 0.0014020329477742728, 'mean_word_length': 1.9791231732776617, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1710736', 'n_tokens_mistral': 946, 'n_tokens_neox': 919, 'n_words': 183}