Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12.x] node-api: allow retrieval of add-on file name #37328

Commits on Mar 17, 2021

  1. node-api: allow retrieval of add-on file name

    Unlike JS-only modules, native add-ons are always associated with a
    dynamic shared object from which they are loaded. Being able to
    retrieve its absolute path is important to native-only add-ons, i.e.
    add-ons that are not themselves being loaded from a JS-only module
    located in the same package as the native add-on itself.
    
    Currently, the file name is obtained at environment construction time
    from the JS `module.filename`. Nevertheless, the presence of `module`
    is not required, because the file name could also be passed in via a
    private property added onto `exports` from the `process.dlopen`
    binding.
    
    As an attempt at future-proofing, the file name is provided as a URL,
    i.e. prefixed with the `file://` protocol.
    
    Fixes: nodejs/node-addon-api#449
    PR-URL: nodejs#37195
    Backport-PR-URL: nodejs#37328
    Co-authored-by: Michael Dawson <mdawson@devrus.com>
    Reviewed-By: Michael Dawson <midawson@redhat.com>
    2 people authored and richardlau committed Mar 17, 2021
    Configuration menu
    Copy the full SHA
    f569209 View commit details
    Browse the repository at this point in the history