Sha256: 6653156659289e7fda3491ed5ddc9fe1e38a9ad50fbe800663153da0d0d12c3c

Contents?: true

Size: 976 Bytes

Versions: 20

Compression:

Stored size: 976 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

20 entries across 10 versions & 1 rubygems

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