Sha256: e4ad318e83695fe06edac5fee82b6a916881e882f55f28af1e004b542502e4e0
Contents?: true
Size: 1008 Bytes
Versions: 10
Compression:
Stored size: 1008 Bytes
Contents
const AbstractHandler = require('./AbstractHandler') class LoadLibraryHandler extends AbstractHandler { requiredParametersCount = 1 constructor() { super() } process(command) { if (command.payload.length < this.requiredParametersCount) { throw new Error("Load Library parameters mismatch") } let {payload} = command let [lib] = payload let pathArray = lib.split(/[/\\]/) let libraryName = pathArray.length > 1 ? pathArray[pathArray.length - 1] : pathArray[0] libraryName = libraryName.replace('.js', '') try { global[libraryName] = require(lib) } catch (error) { try { global[libraryName] = require(`${process.cwd()}/${lib}`) } catch (error) { throw this.process_stack_trace(error, this.constructor.name) } } return 0 } } module.exports = new LoadLibraryHandler()
Version data entries
10 entries across 10 versions & 1 rubygems