ts strict - getAttribute (#863)

* ts strict getAttribute

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* mark xfail

* fix to string

* Remove

* use getAttribute for theme

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ted Patrick
2022-10-21 07:47:44 -05:00
committed by GitHub
parent 58b4df6b3d
commit c352b502c4
11 changed files with 131 additions and 80 deletions

View File

@@ -1,7 +1,7 @@
import toml from '../src/toml'
import { getLogger } from './logger';
import { version } from './runtime';
import { readTextFromPath, showError } from './utils'
import { getAttribute, readTextFromPath, showError } from './utils'
const logger = getLogger('py-config');
@@ -15,10 +15,10 @@ export interface AppConfig extends Record<string, any> {
author_email?: string;
license?: string;
autoclose_loader?: boolean;
runtimes?: Array<RuntimeConfig>;
packages?: Array<string>;
paths?: Array<string>;
plugins?: Array<string>;
runtimes?: RuntimeConfig[];
packages?: string[];
paths?: string[];
plugins?: string[];
pyscript?: PyScriptMetadata;
}
@@ -63,7 +63,7 @@ export function loadConfigFromElement(el: Element): AppConfig {
inlineConfig = {};
}
else {
const configType: string = el.hasAttribute("type") ? el.getAttribute("type") : "toml";
const configType = getAttribute(el, "type") || "toml";
srcConfig = extractFromSrc(el, configType);
inlineConfig = extractFromInline(el, configType);
}
@@ -77,9 +77,8 @@ export function loadConfigFromElement(el: Element): AppConfig {
}
function extractFromSrc(el: Element, configType: string) {
if (el.hasAttribute('src'))
{
const src = el.getAttribute('src');
const src = getAttribute(el, "src")
if (src) {
logger.info('loading ', src)
return validateConfig(readTextFromPath(src), configType);
}