mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 11:15:36 -05:00
Minor refactoring in logger and pyconfig (#1072)
This commit is contained in:
committed by
GitHub
parent
f73d6cd9f2
commit
4b840f7cbd
@@ -75,7 +75,7 @@ export function loadConfigFromElement(el: Element): AppConfig {
|
||||
srcConfig = mergeConfig(srcConfig, defaultConfig);
|
||||
const result = mergeConfig(inlineConfig, srcConfig);
|
||||
result.pyscript = {
|
||||
version: version,
|
||||
version,
|
||||
time: new Date().toISOString(),
|
||||
};
|
||||
return result;
|
||||
@@ -140,7 +140,6 @@ function mergeConfig(inlineConfig: AppConfig, externalConfig: AppConfig): AppCon
|
||||
}
|
||||
|
||||
function parseConfig(configText: string, configType = 'toml') {
|
||||
let config: object;
|
||||
if (configType === 'toml') {
|
||||
try {
|
||||
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
|
||||
@@ -150,7 +149,7 @@ function parseConfig(configText: string, configType = 'toml') {
|
||||
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`
|
||||
);
|
||||
}
|
||||
config = toml.parse(configText);
|
||||
return toml.parse(configText);
|
||||
} catch (err) {
|
||||
const errMessage: string = err.toString();
|
||||
throw new UserError(
|
||||
@@ -160,7 +159,7 @@ function parseConfig(configText: string, configType = 'toml') {
|
||||
}
|
||||
} else if (configType === 'json') {
|
||||
try {
|
||||
config = JSON.parse(configText);
|
||||
return JSON.parse(configText);
|
||||
} catch (err) {
|
||||
const errMessage: string = err.toString();
|
||||
throw new UserError(
|
||||
@@ -174,7 +173,6 @@ function parseConfig(configText: string, configType = 'toml') {
|
||||
`The type of config supplied '${configType}' is not supported, supported values are ["toml", "json"]`
|
||||
);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
function validateConfig(configText: string, configType = 'toml') {
|
||||
|
||||
Reference in New Issue
Block a user