File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
13// File contains a small piece of the source to demonstrate main module
24// of a sample application to be executed in the sandboxed context by
35// another pice of code from `framework.js`. Read README.md for tasks.
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
13// Example showing us how the framework creates an environment (sandbox) for
24// appication runtime, load an application code and passes a sandbox into app
35// as a global context and receives exported application interface
@@ -9,17 +11,17 @@ api.vm = require('vm');
911
1012// Create a hash and turn it into the sandboxed context which will be
1113// the global context of an application
12- let context = { module : { } , console : console } ;
14+ const context = { module : { } , console } ;
1315context . global = context ;
14- let sandbox = api . vm . createContext ( context ) ;
16+ const sandbox = api . vm . createContext ( context ) ;
1517
1618// Read an application source code from the file
17- let fileName = './application.js' ;
19+ const fileName = './application.js' ;
1820api . fs . readFile ( fileName , ( err , src ) => {
1921 // We need to handle errors here
2022
2123 // Run an application in sandboxed context
22- let script = api . vm . createScript ( src , fileName ) ;
24+ const script = api . vm . createScript ( src , fileName ) ;
2325 script . runInNewContext ( sandbox ) ;
2426
2527 // We can access a link to exported interface from sandbox.module.exports
You can’t perform that action at this time.
0 commit comments