File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -158,12 +158,18 @@ <h2>Output:</h2>
158158 fetch ( `https://api.github.com/gists/${ parameters . get ( 'gist' ) } ` )
159159 . then ( ( r ) => r . json ( ) )
160160 . then ( ( data ) => {
161- const state = JSON . parse ( data . files [ 'state.json' ] . content ) ;
162- mode . value = state . mode ;
163- features = new Set ( state . features ) ;
164- const file = data . files [ `code.${ state . mode === 'script' ? 'js' : 'mjs' } ` ] ;
161+ let content ;
162+ if ( data . files [ 'state.json' ] ) {
163+ const state = JSON . parse ( data . files [ 'state.json' ] . content ) ;
164+ mode . value = state . mode ;
165+ features = new Set ( state . features ) ;
166+ content = data . files [ `code.${ state . mode === 'script' ? 'js' : 'mjs' } ` ] . content ;
167+ } else {
168+ const fileName = Object . keys ( data . files ) [ 0 ] ;
169+ content = data . files [ fileName ] . content ;
170+ }
165171 respawn ( ) ;
166- editor . setValue ( file . content ) ;
172+ editor . setValue ( content ) ;
167173 } ) ;
168174 } else {
169175 editor . setValue ( 'print(\'Hello, World!\');' ) ;
You can’t perform that action at this time.
0 commit comments