<commit_before>'use strict';

var expect = require('chai').expect;

var fs = require('fs');

describe('method qfs.fileExists', function() {

    beforeEach(function() {
    });

    it('file exist tmp', function() {

        var promise = fs.existsSync('/tmp');

        console.log(promise);

    });

});
<commit_msg>test fileExistSync<commit_after>'use strict';

var expect = require('chai').expect;

var fs = require('fs');
var path = require("path");

/**
 * https://gist.github.com/tkihira/2367067
 */
var rmdir = function(dir) {
    var list = fs.readdirSync(dir);
    for(var i = 0; i < list.length; i++) {
        var filename = path.join(dir, list[i]);
        var stat = fs.statSync(filename);
        
        if(filename == "." || filename == "..") {
            // pass these files
        } else if(stat.isDirectory()) {
            // rmdir recursively
            rmdir(filename);
        } else {
            // rm fiilename
            fs.unlinkSync(filename);
        }
    }
    fs.rmdirSync(dir);
};

describe('method fs.existsSync', function() {

    beforeEach(function() {
        if(true === fs.existsSync('/tmp/vfs-test')){
            rmdir('/tmp/vfs-test');
        }

        fs.mkdirSync('/tmp/vfs-test');
        fs.mkdirSync('/tmp/vfs-test/exist');
        fs.writeFileSync('/tmp/vfs-test/message.txt', 'Hello Node.js', 'utf8');
    });

    it('succeed on existing dir', function() {

        var exist = fs.existsSync('/tmp/vfs-test/exist');

        expect(exist).to.be.true;

    });

    it('fail on not existing dir', function() {

        var exist = fs.existsSync('/tmp/vfs-test/not-exist');

        expect(exist).to.be.false;

    });

    it('succeed on existing file', function() {

        var exist = fs.existsSync('/tmp/vfs-test/message.txt');

        expect(exist).to.be.true;

    });

    it('fail on not existing file', function() {

        var exist = fs.existsSync('/tmp/vfs-test/no-message.txt');

        expect(exist).to.be.false;

    });

});

{'fraction_non_alphanumeric': 0.18213572854291418, 'fraction_numerical': 0.004491017964071856, 'mean_word_length': 2.2286634460547505, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '6380253', 'n_tokens_mistral': 677, 'n_tokens_neox': 638, 'n_words': 118}