π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
:zap: Refactors console-out into own function
Alicia Sykes4667642dbe43
diff --git a/services/config-validator.js b/services/config-validator.jsindex bc6545e3..b56c4d35 100644--- a/services/config-validator.js+++ b/services/config-validator.js@@ -19,6 +19,9 @@ const ajv = new Ajv(validatorOptions);/* Message printed when validation was successful */const successMsg = () => '\x1b[1m\x1b[32mNo issues found, your configuration is valid :)\x1b[0m\n';+/* Just a wrapper to system's console.log */+const logToConsole = (msg) => { console.log(msg); };+/* Formats error message. ready for printing to the console */const errorMsg = (output) => {const warningFont = '\x1b[103m\x1b[34m';@@ -46,14 +49,14 @@ const setIsValidVariable = (isValid) => {/* Start the validation */const validate = (config) => {- console.log('\nChecking config file against schema...');+ logToConsole('\nChecking config file against schema...');const valid = ajv.validate(schema, config);if (valid) {setIsValidVariable(true);- console.log(successMsg());+ logToConsole(successMsg());} else {setIsValidVariable(false);- console.log(errorMsg(ajv.errors));+ logToConsole(errorMsg(ajv.errors));}};@@ -62,11 +65,11 @@ try {validate(config);} catch (e) { // Something went very wrong...setIsValidVariable(false);- console.log(bigError());- console.log('Please ensure that your config file is present, '+ logToConsole(bigError());+ logToConsole('Please ensure that your config file is present, '+ 'has the correct access rights and is parsable. '+ 'If this warning persists, it may be an issue with the '+ 'validator function. Please raise an issue, and include the following stack trace:\n');console.warn('\x1b[33mStack Trace for config-validator.js:\x1b[0m\n', e);- console.log('\n\n');+ logToConsole('\n\n');}diff --git a/services/update-checker.js b/services/update-checker.jsindex 8f503888..5160fa77 100644--- a/services/update-checker.js+++ b/services/update-checker.js@@ -4,6 +4,10 @@ const currentVersion = require('../package.json').version;const packageUrl = 'https://raw.githubusercontent.com/Lissy93/dashy/master/package.json';+const logToConsole = (msg) => {+ console.log(msg); // eslint-disable-line no-console+};+const makeMsg = (latestVersion) => {const parse = (version) => parseInt(version.replace(/\./g, ''), 10);const difference = parse(latestVersion) - parse(currentVersion);@@ -20,9 +24,9 @@ const makeMsg = (latestVersion) => {axios.get(packageUrl).then((response) => {if (response && response.data && response.data.version) {- console.log(`\nUsing Dashy V-${currentVersion}. Update Check Complete`);- console.log(makeMsg(response.data.version));+ logToConsole(`\nUsing Dashy V-${currentVersion}. Update Check Complete`);+ logToConsole(makeMsg(response.data.version));}}).catch(() => {- console.log('Unable to check for updates');+ logToConsole('Unable to check for updates');});