Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show an error if no config is used at all #1253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/appConfiguration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class AppConfiguration {
_AppConfiguration_configPath.set(this, configPath);
_AppConfiguration_startupConfig.set(this, require('../config')(configPath, appVersion));
_AppConfiguration_legacyConfigStore.set(this, new Store({
name: 'config'
name: 'config',
clearInvalidConfig: true
}));
_AppConfiguration_settingsStore.set(this, new Store({
name: 'settings'
name: 'settings',
clearInvalidConfig: true
}));
}

Expand Down
29 changes: 23 additions & 6 deletions app/config/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
const yargs = require('yargs');
const fs = require('fs');
const path = require('path');
const { LucidLog } = require('lucid-log');

let logger;

function getConfigFilePath(configPath) {
return path.join(configPath, 'config.json');
}

function checkConfigFileExistance(configPath) {
return fs.existsSync(getConfigFilePath(configPath));
}

function getConfigFile(configPath) {
return require(path.join(configPath, 'config.json'));
return require(getConfigFilePath(configPath));
}

function argv(configPath, appVersion) {
let configFile = null;
let configError = null;
try {
configFile = getConfigFile(configPath);
} catch (e) {
configError = e.message;

if (checkConfigFileExistance(configPath)) {
try {
configFile = getConfigFile(configPath);
} catch (e) {
configError = e.message;
}
}

const missingConfig = configFile == null;
configFile = configFile || {};
let config = yargs
Expand Down Expand Up @@ -279,7 +292,11 @@ function argv(configPath, appVersion) {

logger.debug('configPath:', configPath);
if (missingConfig) {
logger.warn('No config file found, using default values');
if (configError) {
logger.warn('Error in config file, using default values:\n' + configError);
} else {
logger.warn('No config file found, using default values');
}
}
logger.debug('configFile:', configFile);

Expand Down
9 changes: 8 additions & 1 deletion com.github.IsmaelMartinez.teams_for_linux.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@
<url type="bugtracker">https://github.com/IsmaelMartinez/teams-for-linux/issues</url>
<launchable type="desktop-id">com.github.IsmaelMartinez.teams_for_linux.desktop</launchable>
<releases>
<release version="1.4.39" date="2024-05-07">
<description>
<ul>
<li>Don't show error in case of missing config file.</li>
</ul>
</description>
</release>
<release version="1.4.38" date="2024-05-06">
<description>
<ul>
<li>Show error message if configuration is invalid</li>
</ul>
</ul>
</description>
</release>
<release version="1.4.37" date="2024-05-04">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teams-for-linux",
"version": "1.4.38",
"version": "1.4.39",
"main": "app/index.js",
"description": "Unofficial client for Microsoft Teams for Linux",
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",
Expand Down
Loading