<commit_before>
var fs = require('fs'),
    path = require('path'),
    should = require('should'),
    recursive = require('recursive-fs');
require('colors');

var prompt = require('../common/prompt');


describe('command line', function () {
    before(function (done) {
        var dpath = path.resolve(__dirname, 'project');
        recursive.rmdirr(dpath, function (err) {
            fs.mkdirSync(path.resolve(__dirname, 'project'));
            done();
        });
    });

    it('should return an error on non existent directory', function (done) {
        var params = [path.resolve(__dirname, '../../app.js'), 'non-existing-dir'],
            expected = 'Config directory path doesn\'t exists!'.red;
        
        prompt.start(params, expected, function (err) {
            done(err);
        });
    });

    it('should prompt for data on non existent config files', function (done) {	
        var params = [path.resolve(__dirname, 'wrapper.js'), 'test/app/project'];
        var data = [
            {in: 'express-admin-simple', out: 'Database user:'},
            {in: 'liolio', out: 'Database password:'},
            {in: 'karamba', out: 'Server port:'},
            {in: '\n', out: 'Admin user:'},
            {in: 'admin', out: 'Admin password:'},
            {in: '11aaAA', out: 'end'}
        ];
        prompt.start(params, 'Database name:', function (err) {
            (function loop (i, cb) {
                if (i == 6) return cb();
                prompt.next(data[i].in, data[i].out, function (err) {
                    if (err) return cb(err);
                    loop(++i, cb);
                });
            }(0, function (err) {
                if (err) return done(err);
                should.deepEqual(require('./project/custom'), {});
                should.deepEqual(require('./project/settings'), {});
                should.deepEqual(require('./project/config'), {
                    mysql: {database: 'express-admin-simple', user: 'liolio', password:'<PASSWORD>'},
                    server: {port: 3000},<commit_msg>Fixed the app/cmd test<commit_after>
var fs = require('fs'),
    path = require('path'),
    should = require('should'),
    recursive = require('recursive-fs');
require('colors');

var prompt = require('../common/prompt');


describe('command line', function () {
    before(function (done) {
        var dpath = path.resolve(__dirname, 'project');
        recursive.rmdirr(dpath, function (err) {
            fs.mkdirSync(path.resolve(__dirname, 'project'));
            done();
        });
    });

    it('should return an error on non existent directory', function (done) {
        var params = [path.resolve(__dirname, '../../app.js'), 'non-existing-dir'],
            expected = 'Config directory path doesn\'t exists!'.red;
        
        prompt.start(params, expected, function (err) {
            done(err);
        });
    });

    it('should prompt for data on non existent config files', function (done) {	
        var params = [path.resolve(__dirname, 'wrapper.js'), 'test/app/project'];
        var data = [
            {in: 'mysql', out: 'Database name:'},
            {in: 'express-admin-simple', out: 'Database user:'},
            {in: 'liolio', out: 'Database password:'},
            {in: 'karamba', out: 'Server port:'},
            {in: '\n', out: 'Admin user:'},
            {in: 'admin', out: 'Admin password:'},
            {in: '11aaAA', out: 'end'}
        ];
        prompt.start(params, 'Database type:', function (err) {
            (function loop (i, cb) {
                if (i == 7) return cb();
                prompt.next(data[i].in, data[i].out, function (err) {
                    if (err) return cb(err);
                    loop(++i, cb);
                });
            }(0, function (err) {
                if (err) return done(err);
                should.deepEqual(require('./project/custom'), {});
                should.deepEqual(require('./project/settings'), {});
                should.deepEqual(require('./project/config'), {
                    mysql: {database: 'express-admin-simple', user: 'liolio', password:'<PASSWORD>'},
                    server: {port: 3000},
{'fraction_non_alphanumeric': 0.17347670250896058, 'fraction_numerical': 0.0038231780167264037, 'mean_word_length': 2.0028694404591105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5347185', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1152, 'n_words': 297}