Skip to content

Commit

Permalink
Add support for Node 18
Browse files Browse the repository at this point in the history
Add compatibility with Node 18.0.0
  • Loading branch information
mmomtchev authored Apr 23, 2022
1 parent 3aaaf1b commit 16fa322
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
- TRAVIS_NODE_VERSION="15"
- TRAVIS_NODE_VERSION="16"
- TRAVIS_NODE_VERSION="17"
- TRAVIS_NODE_VERSION="18"
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="2.0.18"
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="3.1.13"
- TRAVIS_NODE_VERSION="lts/*" ELECTRON_VERSION="4.2.12"
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ environment:
- nodejs_version: "15"
- nodejs_version: "16"
- nodejs_version: "17"
- nodejs_version: "18"

# Install scripts. (runs after repo cloning)
install:
Expand Down
6 changes: 5 additions & 1 deletion nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define NODE_15_0_MODULE_VERSION 88
#define NODE_16_0_MODULE_VERSION 93
#define NODE_17_0_MODULE_VERSION 102
#define NODE_18_0_MODULE_VERSION 108

#ifdef _MSC_VER
# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800)
Expand Down Expand Up @@ -2549,7 +2550,10 @@ inline void SetAccessor(
, obj
, settings
, attribute
, signature);
#if (NODE_MODULE_VERSION < NODE_18_0_MODULE_VERSION)
, signature
#endif
);
}

inline bool SetAccessor(
Expand Down
12 changes: 10 additions & 2 deletions test/cpp/news.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ NAN_METHOD(NewScript) {
}

NAN_METHOD(NewScript2) {
v8::ScriptOrigin origin(New<v8::String>("x").ToLocalChecked());
v8::ScriptOrigin origin(
#if NODE_MODULE_VERSION >= NODE_18_0_MODULE_VERSION
info.GetIsolate(),
#endif
New<v8::String>("x").ToLocalChecked());
v8::Local<UnboundScript> script =
New<UnboundScript>(
New("2+4").ToLocalChecked()
Expand All @@ -131,7 +135,11 @@ NAN_METHOD(CompileScript) {
}

NAN_METHOD(CompileScript2) {
v8::ScriptOrigin origin(New<v8::String>("x").ToLocalChecked());
v8::ScriptOrigin origin(
#if NODE_MODULE_VERSION >= NODE_18_0_MODULE_VERSION
info.GetIsolate(),
#endif
New<v8::String>("x").ToLocalChecked());
v8::Local<BoundScript> script =
CompileScript(New("2+4").ToLocalChecked(), origin).ToLocalChecked();
info.GetReturnValue().Set(
Expand Down

0 comments on commit 16fa322

Please sign in to comment.