@@ -25,8 +25,7 @@ const hooks = {
25
25
} ;
26
26
27
27
const validate = ( config , result ) => {
28
- if ( typeof result === 'boolean' )
29
- throw `Invalid source: ${ config } ` ;
28
+ if ( typeof result === "boolean" ) throw `Invalid source: ${ config } ` ;
30
29
return result ;
31
30
} ;
32
31
@@ -52,20 +51,23 @@ async function execute({ currentTarget }) {
52
51
details . configURL = relative_url ( config ) ;
53
52
if ( config . endsWith ( ".toml" ) ) {
54
53
const [ { parse } , toml ] = await Promise . all ( [
55
- import ( /* webpackIgnore: true */ "../3rd-party/toml.js" ) ,
56
- fetch ( config ) . then ( ( r ) => ( r . ok && r . text ( ) ) ) ,
54
+ import (
55
+ /* webpackIgnore: true */ "../3rd-party/toml.js"
56
+ ) ,
57
+ fetch ( config ) . then ( ( r ) => r . ok && r . text ( ) ) ,
57
58
] ) ;
58
59
details . config = parse ( validate ( config , toml ) ) ;
59
60
} else if ( config . endsWith ( ".json" ) ) {
60
- const json = await fetch ( config ) . then ( ( r ) => ( r . ok && r . json ( ) ) ) ;
61
+ const json = await fetch ( config ) . then (
62
+ ( r ) => r . ok && r . json ( ) ,
63
+ ) ;
61
64
details . config = validate ( config , json ) ;
62
65
} else {
63
66
details . configURL = relative_url ( "./config.txt" ) ;
64
67
details . config = JSON . parse ( config ) ;
65
68
}
66
69
details . version = offline_interpreter ( details . config ) ;
67
- }
68
- catch ( error ) {
70
+ } catch ( error ) {
69
71
notify ( error ) ;
70
72
return ;
71
73
}
@@ -212,9 +214,11 @@ const init = async (script, type, interpreter) => {
212
214
const { src } = script ;
213
215
if ( src ) {
214
216
try {
215
- source = validate ( src , await fetch ( src ) . then ( ( b ) => ( b . ok && b . text ( ) ) ) ) ;
216
- }
217
- catch ( error ) {
217
+ source = validate (
218
+ src ,
219
+ await fetch ( src ) . then ( ( b ) => b . ok && b . text ( ) ) ,
220
+ ) ;
221
+ } catch ( error ) {
218
222
notify ( error ) ;
219
223
return ;
220
224
}
0 commit comments