@@ -490,31 +490,34 @@ export class ScriptController {
490490 }
491491
492492 public buildScriptCache ( script : Script ) : Promise < ScriptCache > {
493- // eslint-disable-next-line @typescript-eslint/no-misused-promises
494- return new Promise ( async resolve => {
495- const ret : ScriptCache = < ScriptCache > Object . assign ( { } , script ) ;
496-
497- // 自定义配置
498- for ( const key in ret . metadata ) {
499- if ( ret . selfMetadata && ret . selfMetadata [ key ] ) {
500- ret . metadata [ key ] = ret . selfMetadata [ key ] ;
493+ return new Promise ( resolve => {
494+ const handler = async ( ) => {
495+ const ret : ScriptCache = < ScriptCache > Object . assign ( { } , script ) ;
496+
497+ // 自定义配置
498+ if ( ret . selfMetadata ) {
499+ ret . metadata = Object . assign ( { } , ret . metadata ) ;
500+ for ( const key in ret . selfMetadata ) {
501+ ret . metadata [ key ] = ret . selfMetadata [ key ] ;
502+ }
501503 }
502- }
503504
504- ret . value = await this . getScriptValue ( ret ) ;
505+ ret . value = await this . getScriptValue ( ret ) ;
505506
506- ret . resource = await this . getResources ( ret ) ;
507+ ret . resource = await this . getResources ( ret ) ;
507508
508- ret . flag = randomString ( 16 ) ;
509- ret . code = compileScriptCode ( ret ) ;
509+ ret . flag = randomString ( 16 ) ;
510+ ret . code = compileScriptCode ( ret ) ;
510511
511- ret . grantMap = { } ;
512+ ret . grantMap = { } ;
512513
513- ret . metadata [ 'grant' ] ?. forEach ( ( val : string ) => {
514- ret . grantMap [ val ] = 'ok' ;
515- } ) ;
514+ ret . metadata [ 'grant' ] ?. forEach ( ( val : string ) => {
515+ ret . grantMap [ val ] = 'ok' ;
516+ } ) ;
516517
517- resolve ( ret ) ;
518+ resolve ( ret ) ;
519+ }
520+ void handler ( ) ;
518521 } ) ;
519522 }
520523
0 commit comments