var fs = require('fs')
var path = require('path')
var clicolour = require('cli-color')
var error = require('../../../libs/error/bsod.js')
var files = ["app.js", "node_modules", "libs"];
var i;
exports.checkFiles = function checkFiles(x){
// TODO: Fix issue where files[i] is undefined
console.log(clicolour.yellowBright("ALPHA:")+"Checking out files need fixing, does in fact check out files correctly");
for (var i = 0; i < files.length; i++) {
fs.stat(files[i], function(err, stat){
if(err === null){
return console.log('Checked out file '+files[i]+"..."+clicolour.greenBright("OK"));
console.log(i);
}
else if( err.code == 'ENOENT'){
console.log('Checked out file '+files[i]+"..."+clicolour.redBright("ERROR!"));
throw error.throwError("BOOT_"+err.code+"_CHECKS_NOT_FOUND:"+files[i], err, err.code);
}
else{
console.log('Checked out file '+files[i]+"..."+clicolour.redBright("ERROR!"));
throw error.throwError("BOOT_CHECKS_FILES_"+err.code+":"+files[i], err, err.code);
}
});
}
});
};
Output:
Checked out file undefined...OK
Checked out file undefined...OK
Checked out file undefined...OK
File: boot/libs/checks/checkFile.js Code:
Output: