@@ -25,7 +25,7 @@ export class AppsEngineVM2Runtime extends AppsEngineRuntime {
2525 timeout : options ?. timeout ,
2626 sandbox : {
2727 ...AppsEngineVM2Runtime . defaultNodeVMOptions . sandbox ,
28- ...sandbox || { } ,
28+ ...( sandbox || { } ) ,
2929 } ,
3030 } ;
3131
@@ -35,7 +35,6 @@ export class AppsEngineVM2Runtime extends AppsEngineRuntime {
3535 external : [ '@rocket.chat/apps-engine' , 'uuid' ] ,
3636 builtin : [ 'path' , 'url' , 'crypto' , 'buffer' , 'stream' , 'net' , 'http' , 'https' , 'zlib' , 'util' , 'punycode' , 'os' , 'querystring' ] ,
3737 resolve : ( moduleName , p ) => {
38- console . log ( 'Resolving ' . concat ( moduleName , ' from ' ) . concat ( p ) ) ;
3938 return path . resolve ( p + '/npm/node_modules/' + moduleName ) ;
4039 } ,
4140 context : 'sandbox' ,
@@ -45,10 +44,10 @@ export class AppsEngineVM2Runtime extends AppsEngineRuntime {
4544 }
4645 const vm = new NodeVM ( vmOptions ) ;
4746
48- const app = ( vm . run ( code , {
47+ const app = vm . run ( code , {
4948 filename : options ?. filename || 'app.js' ,
5049 require : ( mod : string ) => resolve ( mod , vm . require . bind ( vm ) ) ,
51- } as any ) ) ;
50+ } as any ) ;
5251 // Get first exported object, vm2 does not return the last value when it's an assignment as intern vm
5352 // so we use the first exported value as the class.
5453 return options ?. returnAllExports ? app : app && app [ Object . keys ( app ) [ 0 ] ] ;
@@ -75,11 +74,13 @@ export class AppsEngineVM2Runtime extends AppsEngineRuntime {
7574 } ) ;
7675
7776 // Clean up the sandbox after the code has run
78- this . vm . setGlobals ( Object . keys ( sandbox ) . reduce ( ( acc , key ) => {
79- acc [ key ] = undefined ;
77+ this . vm . setGlobals (
78+ Object . keys ( sandbox ) . reduce ( ( acc , key ) => {
79+ acc [ key ] = undefined ;
8080
81- return acc ;
82- } , { } as typeof sandbox ) ) ;
81+ return acc ;
82+ } , { } as typeof sandbox ) ,
83+ ) ;
8384
8485 return result ;
8586 }
0 commit comments