MCPcopy Create free account
hub / github.com/breck7/scroll / _requireInVmNodeJsRootParser

Method _requireInVmNodeJsRootParser

external/.scrollLibs.js:19894–19913  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

19892 return this
19893 }
19894 _requireInVmNodeJsRootParser(code) {
19895 const vm = require("vm")
19896 const path = require("path")
19897 // todo: cleanup up
19898 try {
19899 Object.keys(GlobalNamespaceAdditions).forEach(key => {
19900 global[key] = require("./" + GlobalNamespaceAdditions[key])
19901 })
19902 global.require = require
19903 global.__dirname = this._dirName
19904 global.module = {}
19905 return vm.runInThisContext(code)
19906 } catch (err) {
19907 // todo: figure out best error pattern here for debugging
19908 console.log(`Error in compiled parsers code for language "${this.parsersName}"`)
19909 // console.log(new Particle(code).toStringWithLineNumbers())
19910 console.log(err)
19911 throw err
19912 }
19913 }
19914 examplesToTestBlocks(rootParser = this.compileAndReturnRootParser(), expectedErrorMessage = "") {
19915 const testBlocks = {}
19916 this.validConcreteAndAbstractParserDefinitions.forEach(def =>

Callers 1

Calls 2

forEachMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected