File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 17
17
"@rollup/plugin-node-resolve" : " ^11.0.0" ,
18
18
"@rollup/plugin-typescript" : " ^8.3.2" ,
19
19
"@tsconfig/svelte" : " ^1.0.0" ,
20
+ "@types/js-yaml" : " ^4.0.5" ,
20
21
"@typescript-eslint/eslint-plugin" : " ^5.20.0" ,
21
22
"@typescript-eslint/parser" : " ^5.20.0" ,
22
23
"autoprefixer" : " ^10.4.7" ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export class PyEnv extends HTMLElement {
16
16
shadow : ShadowRoot ;
17
17
wrapper : HTMLElement ;
18
18
code : string ;
19
- environment : any ;
19
+ environment : unknown ;
20
20
runtime : any ;
21
21
env : string [ ] ;
22
22
paths : string [ ] ;
@@ -32,22 +32,28 @@ export class PyEnv extends HTMLElement {
32
32
this . code = this . innerHTML ;
33
33
this . innerHTML = '' ;
34
34
35
- const env = [ ] ;
35
+ const env : string [ ] = [ ]
DF80
;
36
36
const paths : string [ ] = [ ] ;
37
37
38
38
this . environment = jsyaml . load ( this . code ) ;
39
39
if ( this . environment === undefined ) return ;
40
40
41
- for ( const entry of this . environment ) {
41
+ for ( const entry of Array . isArray ( this . environment ) ? this . environment : [ ] ) {
42
42
if ( typeof entry == 'string' ) {
43
43
env . push ( entry ) ;
44
- } else if ( entry . hasOwnProperty ( 'paths' ) ) {
45
- for ( const path of entry . paths ) {
46
- paths . push ( path ) ;
44
+ } else if ( entry && typeof entry === 'object' ) {
45
+ const obj = < Record < string , unknown > > entry ;
46
+ for ( const path of Array . isArray ( obj . paths ) ? obj . paths : [ ] ) {
47
+ if ( typeof path === 'string' ) {
48
+ paths . push ( path ) ;
49
+ }
47
50
}
48
51
}
49
52
}
50
53
54
+ this . env = env ;
55
+ this . paths = paths ;
56
+
51
57
async function loadEnv ( ) {
52
58
await loadPackage ( env , runtime ) ;
53
59
console . log ( 'environment loaded' ) ;
You can’t perform that action at this time.
0 commit comments