Skip to content

Commit

Permalink
fix: fixed error: ‘class v8::Object’ has no member named 'CreationCon…
Browse files Browse the repository at this point in the history
…text' (#44)

* fix: fixed error: ‘class v8::Object’ has no member named ‘CreationContext’; allowing node-gyp to rebind with node-postal, which enables node-postal to be used on Node v20.5.0

* feat: add node v16 and v20 to github actions matrix

* fix: updated workflow script to run on push and pull request events

* fix: updated actions/checkout@v2 to v3 as the former was deprecated

* test: trying to get the bindings file made/located correctly

* fix: removed incorrect cd step

* feat: added fail-fast so jobs will continue running after a node version test fails in the matrix

* feat/test: set the context depending on the node version; node v16+ use new update, else use old way

* fix/test:  added node version header to expand.cc and parser.cc

* test: changed node_version header to node header

* fix: reverting back to state where node 16,18,20 tests worked...

* fix/test: reverted github actions to v2 from v3...

* test: attempt to get tests to pass for node v16+

* fix: re-added line in ParseAddress that had been incorrectly removed

* fix: depending on node version call the right context function

* fix: removed typo
  • Loading branch information
zack09holland authored Jan 22, 2024
1 parent 4a58dfa commit a7bf136
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: 'Continuous Integration'
on: push
on: [push, pull_request]
jobs:
unit-tests:
runs-on: '${{ matrix.os }}'
continue-on-error: ${{ matrix.status != 'current' }}
strategy:
fail-fast: false
matrix:
status: ['current']
os:
Expand All @@ -13,6 +14,8 @@ jobs:
- 12.x
- 14.x
- 16.x
- 18.x
- 20.x
include:
- os: ubuntu-20.04
node-version: 8.x
Expand All @@ -26,7 +29,7 @@ jobs:
shell: bash
run: |
sudo apt-get update
sudo apt-get install curl autoconf automake libtool pkg-config
sudo apt-get install build-essential curl autoconf automake libtool pkg-config
- name: 'Create working directories'
shell: bash
run: |
Expand Down
9 changes: 7 additions & 2 deletions src/expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ static void cleanup(void*) {
}

void init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();

// Check Node.js version
#if NODE_MAJOR_VERSION >= 16
v8::Local<v8::Context> context = exports->GetCreationContext().ToLocalChecked();
#else
v8::Local<v8::Context> context = exports->CreationContext();
#endif

if (!libpostal_setup() || !libpostal_setup_language_classifier()) {
Nan::ThrowError("Could not load libpostal");
return;
Expand Down
7 changes: 6 additions & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ static void cleanup(void*) {
}

void init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();
// Check Node.js version
#if NODE_MAJOR_VERSION >= 16
v8::Local<v8::Context> context = exports->GetCreationContext().ToLocalChecked();
#else
v8::Local<v8::Context> context = exports->CreationContext();
#endif

if (!libpostal_setup() || !libpostal_setup_parser()) {
Nan::ThrowError("Could not load libpostal");
Expand Down

0 comments on commit a7bf136

Please sign in to comment.