Skip to content

Commit 661cd59

Browse files
Root-Coremhdawson
andauthored
Fixed build with newer Node.js versions (#205)
Co-authored-by: Michael Dawson <mdawson@devrus.com>
1 parent 7c045d3 commit 661cd59

File tree

9 files changed

+15
-7
lines changed

9 files changed

+15
-7
lines changed

.github/workflows/nodejs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [14.x, 16.x, 18.x]
18+
node-version: [16.x, 18.x, 20.x]
1919
operating-system: [ubuntu-latest, windows-2019, macos-latest]
2020

2121
steps:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
2+
build_with_cmake/
23
node_modules/
34
Debug/
45
Release/

1_hello_world/nan/hello.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) {
55
}
66

77
void Init(v8::Local<v8::Object> exports) {
8-
v8::Local<v8::Context> context = exports->CreationContext();
8+
v8::Local<v8::Context> context =
9+
exports->GetCreationContext().ToLocalChecked();
910
exports->Set(context,
1011
Nan::New("hello").ToLocalChecked(),
1112
Nan::New<v8::FunctionTemplate>(Method)

2_function_arguments/nan/addon.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ void Add(const Nan::FunctionCallbackInfo<v8::Value>& info) {
2121
}
2222

2323
void Init(v8::Local<v8::Object> exports) {
24-
v8::Local<v8::Context> context = exports->CreationContext();
24+
v8::Local<v8::Context> context =
25+
exports->GetCreationContext().ToLocalChecked();
2526
exports->Set(context,
2627
Nan::New("add").ToLocalChecked(),
2728
Nan::New<v8::FunctionTemplate>(Add)

4_object_factory/nan/addon.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
1111
}
1212

1313
void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
14-
v8::Local<v8::Context> context = exports->CreationContext();
14+
v8::Local<v8::Context> context =
15+
exports->GetCreationContext().ToLocalChecked();
1516
module->Set(context,
1617
Nan::New("exports").ToLocalChecked(),
1718
Nan::New<v8::FunctionTemplate>(CreateObject)

6_object_wrap/nan/myobject.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ MyObject::MyObject(double value) : value_(value) {}
77
MyObject::~MyObject() {}
88

99
void MyObject::Init(v8::Local<v8::Object> exports) {
10-
v8::Local<v8::Context> context = exports->CreationContext();
10+
v8::Local<v8::Context> context =
11+
exports->GetCreationContext().ToLocalChecked();
1112
Nan::HandleScope scope;
1213

1314
// Prepare constructor template

7_factory_wrap/nan/addon.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
66
}
77

88
void InitAll(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
9-
v8::Local<v8::Context> context = exports->CreationContext();
9+
v8::Local<v8::Context> context =
10+
exports->GetCreationContext().ToLocalChecked();
1011

1112
Nan::HandleScope scope;
1213

8_passing_wrapped/nan/addon.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void Add(const Nan::FunctionCallbackInfo<v8::Value>& info) {
1919
}
2020

2121
void InitAll(v8::Local<v8::Object> exports) {
22-
v8::Local<v8::Context> context = exports->CreationContext();
22+
v8::Local<v8::Context> context =
23+
exports->GetCreationContext().ToLocalChecked();
2324

2425
MyObject::Init();
2526

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dependencies": {
2222
"chalk": "^3.0.0",
2323
"clang-format": "^1.4.0",
24+
"cmake-js": "^7.1.1",
2425
"semver": "^7.1.3"
2526
},
2627
"devDependencies": {

0 commit comments

Comments
 (0)