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

Version Path
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.1.14 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.1.13 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.1.12 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Nodejs/Windows/X64/core/handler/LoadLibraryHandler.js