Skip to content

Commit

Permalink
Napi search path (#490)
Browse files Browse the repository at this point in the history
Co-authored-by: Bret Ambrose <bambrose@amazon.com>
  • Loading branch information
bretambrose and Bret Ambrose committed Jan 18, 2024
1 parent 7dc8379 commit d1729bf
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/native/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,27 @@ if (existsSync(dist)) {

const bin_path = path.resolve(source_root, 'bin');

const search_paths = [
path.join(bin_path, platformDir, binary_name),
let search_paths = [
path.join(bin_path, platformDir, binary_name) + '.node',
];

/*
* Environment variables can inject (at lower-priority) paths into the search process as well. Support both relative
* and absolute path overrides.
*/
let relative_path = process.env.AWS_CRT_NODEJS_BINARY_RELATIVE_PATH;
if (relative_path) {
let final_path = path.resolve(__dirname, ...relative_path.split(path.sep))
search_paths.push(final_path);
}

if (process.env.AWS_CRT_NODEJS_BINARY_ABSOLUTE_PATH) {
search_paths.push(process.env.AWS_CRT_NODEJS_BINARY_ABSOLUTE_PATH);
}

let binding;
for (const path of search_paths) {
if (existsSync(path + '.node')) {
if (existsSync(path)) {
binding = require(path);
break;
}
Expand Down

5 comments on commit d1729bf

@justin-masse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bretambrose looks like this got stuck in the GHAs? Is it possible this can get published ASAP as a patch version? I'm attempting to use this workaround to work in lambda w/ es build by providing the direct path to the binary that i've included in a layer.

@bretambrose
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure what you mean by GHA. PR has been merged, but nothing has been released yet.

@justin-masse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, meant the checks that happened post-merge. Looks like 2 codebuild jobs etc and one was still "running".

Do you know roughly when this might be released? Just trying to orchestrate the work to inject this lambda layer + env var across our lambdas to implement aws-crt

@bretambrose
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can start a release now, but I feel like it should be a minor bump, and I don't know if that will work for immediate consumption if you're pulling the CRT through some other dependency.

@justin-masse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using aws-crt directly for the implementation of sigv4a so I can give that a shot now! Thank you!

Please sign in to comment.