<commit_before>
var generatetask = require('../source/ajgenesis/tasks/generate'),
    createtask = require('../create'),
    path = require('path'),
    fs = require('fs'),
    ajgenesis = require('ajgenesis');

exports['generate'] = function (test) {
    test.async();
    
    var cwd = process.cwd();
    
    process.chdir('test');
    
    var model = ajgenesis.loadModel();
    
    test.ok(model.entities);
    test.ok(Array.isArray(model.entities));
    test.equal(model.entities.length, 2);
    
    if (fs.existsSync('build') && !fs.existsSync(path.join('build', 'node_modules')))
        removeDirSync('build');
        
    createtask(null, ['build'], ajgenesis, function (err, result) {
        process.chdir('build');
        
        generatetask(model, [], ajgenesis, function (err, result) {
            test.equal(err, null);
            test.equal(result, null);

            test.ok(fs.existsSync('app.js'));
            test.ok(fs.existsSync('package.json'));
            
            var pack = require(path.resolve('package.json'));
            
            test.ok(pack);
            test.equal(pack.name, 'myproject');
            test.equal(pack.version, '0.0.1');
                    
            //test.ok(fs.existsSync(path.join('views', 'index.ejs')));
            //test.ok(fs.existsSync(path.join('views', 'error.ejs')));
            test.ok(fs.existsSync(path.join('views', 'header.ejs')));
            test.ok(fs.existsSync(path.join('views', 'headerjumbo.ejs')));
            test.ok(fs.existsSync(path.join('views', 'footer.ejs')));<commit_msg>Fix load package in generate test<commit_after>
var generatetask = require('../source/ajgenesis/tasks/generate'),
    createtask = require('../create'),
    path = require('path'),
    fs = require('fs'),
    ajgenesis = require('ajgenesis');

exports['generate'] = function (test) {
    test.async();
    
    var cwd = process.cwd();
    
    process.chdir('test');
    
    var model = ajgenesis.loadModel();
    
    test.ok(model.entities);
    test.ok(Array.isArray(model.entities));
    test.equal(model.entities.length, 2);
    
    if (fs.existsSync('build') && !fs.existsSync(path.join('build', 'node_modules')))
        removeDirSync('build');
        
    createtask(null, ['build'], ajgenesis, function (err, result) {
        process.chdir('build');
        
        generatetask(model, [], ajgenesis, function (err, result) {
            test.equal(err, null);
            test.equal(result, null);

            test.ok(fs.existsSync('app.js'));
            test.ok(fs.existsSync('package.json'));
            
            var packjson = fs.readFileSync('package.json').toString();
            var pack;
            
            eval("pack = " + packjson);

            test.ok(pack);
            test.equal(pack.name, 'myproject');
            test.equal(pack.version, '0.0.1');
                    
            //test.ok(fs.existsSync(path.join('views', 'index.ejs')));
            //test.ok(fs.existsSync(path.join('views', 'error.ejs')));
            test.ok(fs.existsSync(path.join('views', 'header.ejs')));
            test.ok(fs.existsSync(path.join('views', 'headerjumbo.ejs')));
            test.ok(fs.existsSync(path.join('views', 'footer.ejs')));
{'fraction_non_alphanumeric': 0.18111931119311192, 'fraction_numerical': 0.0024600246002460025, 'mean_word_length': 2.3160040774719675, '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': '1498903', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1006, 'n_words': 144}