More console -> Logger conversions

This commit is contained in:
rejas
2020-05-31 22:12:26 +02:00
parent 2330b166f6
commit 008ac2876b
6 changed files with 30 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ const fs = require("fs");
const rootPath = path.resolve(__dirname + "/../");
const config = require(rootPath + "/.eslintrc.json");
const Logger = require(rootPath + "/js/logger.js");
const Log = require(rootPath + "/js/logger.js");
const Utils = require(rootPath + "/js/utils.js");
/* getConfigFile()
@@ -37,19 +37,19 @@ function checkConfigFile() {
const configFileName = getConfigFile();
// Check if file is present
if (fs.existsSync(configFileName) === false) {
Logger.error(Utils.colors.error("File not found: "), configFileName);
Log.error(Utils.colors.error("File not found: "), configFileName);
return;
}
// check permission
try {
fs.accessSync(configFileName, fs.F_OK);
} catch (e) {
Logger.log(Utils.colors.error(e));
Log.log(Utils.colors.error(e));
return;
}
// Validate syntax of the configuration file.
Logger.info(Utils.colors.info("Checking file... "), configFileName);
Log.info(Utils.colors.info("Checking file... "), configFileName);
// I'm not sure if all ever is utf-8
fs.readFile(configFileName, "utf-8", function (err, data) {
@@ -58,12 +58,12 @@ function checkConfigFile() {
}
const messages = linter.verify(data, config);
if (messages.length === 0) {
Logger.log("Your configuration file doesn't contain syntax errors :)");
Log.log("Your configuration file doesn't contain syntax errors :)");
return true;
} else {
// In case the there errors show messages and return
messages.forEach((error) => {
Logger.log("Line", error.line, "col", error.column, error.message);
Log.log("Line", error.line, "col", error.column, error.message);
});
}
});