File tree Expand file tree Collapse file tree 11 files changed +107
-6
lines changed
async_work_thread_safe_function/node-api
thread_safe_function_round_trip/node-api Expand file tree Collapse file tree 11 files changed +107
-6
lines changed Original file line number Diff line number Diff line change 11build /
22node_modules /
3+ Debug /
4+ Release /
5+ * .lock
6+ * .log
7+ npm-debug.log *
8+
9+ .idea /
10+ .vscode /
11+ .DS_Store
Original file line number Diff line number Diff line change 1+ language : node_js
2+ node_js :
3+ - " 8"
4+ - " 10"
5+ # - "12" enable this when fix issue on Node.js 12
6+ cache :
7+ npm
8+ before_script :
9+ - npx envinfo
10+ script :
11+ - npm install
12+ - npm test
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ void MyObject::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
3737 const int argc = 1 ;
3838 v8::Local<v8::Value> argv[argc] = { info[0 ] };
3939 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
40- info.GetReturnValue ().Set (cons->NewInstance (argc, argv));
40+ v8::Local<v8::Context> context = info.GetIsolate ()->GetCurrentContext ();
41+ info.GetReturnValue ().Set (
42+ cons->NewInstance (context, argc, argv).ToLocalChecked ());
4143 }
4244}
4345
@@ -61,5 +63,7 @@ void MyObject::Multiply(const Nan::FunctionCallbackInfo<v8::Value>& info) {
6163 const int argc = 1 ;
6264 v8::Local<v8::Value> argv[argc] = { Nan::New (obj->value_ * multiple) };
6365
64- info.GetReturnValue ().Set (cons->NewInstance (argc, argv));
66+ v8::Local<v8::Context> context = info.GetIsolate ()->GetCurrentContext ();
67+ info.GetReturnValue ().Set (
68+ cons->NewInstance (context, argc, argv).ToLocalChecked ());
6569}
Original file line number Diff line number Diff line change 66 "private" : true ,
77 "gypfile" : true ,
88 "dependencies" : {
9- "bindings" : " ~1.2.1 " ,
10- "nan" : " ^2.0 .0"
9+ "bindings" : " ~1.5.0 " ,
10+ "nan" : " ^2.14 .0"
1111 }
1212}
Original file line number Diff line number Diff line change @@ -37,7 +37,10 @@ v8::Local<v8::Object> MyObject::NewInstance(v8::Local<v8::Value> arg) {
3737 const unsigned argc = 1 ;
3838 v8::Local<v8::Value> argv[argc] = { arg };
3939 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
40- v8::Local<v8::Object> instance = cons->NewInstance (argc, argv);
40+ v8::Local<v8::Context> context =
41+ v8::Isolate::GetCurrent ()->GetCurrentContext ();
42+ v8::Local<v8::Object> instance =
43+ cons->NewInstance (context, argc, argv).ToLocalChecked ();
4144
4245 return scope.Escape (instance);
4346}
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ v8::Local<v8::Object> MyObject::NewInstance(v8::Local<v8::Value> arg) {
3131 const unsigned argc = 1 ;
3232 v8::Local<v8::Value> argv[argc] = { arg };
3333 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
34- v8::Local<v8::Object> instance = cons->NewInstance (argc, argv);
34+ v8::Local<v8::Context> context =
35+ v8::Isolate::GetCurrent ()->GetCurrentContext ();
36+ v8::Local<v8::Object> instance =
37+ cons->NewInstance (context, argc, argv).ToLocalChecked ();
3538
3639 return scope.Escape (instance);
3740}
Original file line number Diff line number Diff line change 11Node.js Addon Examples
22=========================================
3+ [ ![ Build Status] ( https://travis-ci.org/nodejs/node-addon-examples.svg?branch=master )] ( https://travis-ci.org/nodejs/node-addon-examples )
4+
35** A repository of [ Node.js Addons] ( https://nodejs.org/api/addons.html#addons_c_addons ) examples.**
46
57Implementations of examples are named either after Node.js versions (` node_0.10 ` ,
Original file line number Diff line number Diff line change 77 "dependencies" : {
88 "bindings" : " ~1.2.1"
99 },
10+ "engines" : {
11+ "node" : " >= 10.6.0"
12+ },
1013 "scripts" : {
1114 "test" : " node index.js"
1215 },
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " node-addon-examples" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Node.js Addon Examples" ,
5+ "main" : " test_all.js" ,
6+ "scripts" : {
7+ "test" : " node test_all.js"
8+ },
9+ "dependencies" : {
10+ "chalk" : " ^2.4.2" ,
11+ "semver" : " ^6.3.0"
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+ const { execSync } = require ( 'child_process' )
4+ const chalk = require ( 'chalk' )
5+ const semver = require ( 'semver' )
6+
7+ const excludeFolder = [ 'node_modules' ]
8+
9+ function getAllTests ( ) {
10+ return fs
11+ . readdirSync ( './' )
12+ . filter ( i => {
13+ return (
14+ ! i . startsWith ( '.' ) &&
15+ fs . statSync ( i ) . isDirectory ( ) &&
16+ ! excludeFolder . includes ( i )
17+ )
18+ } )
19+ . map ( i => {
20+ const p = path . join ( __dirname , i )
21+ const tests = fs
22+ . readdirSync ( p )
23+ . filter ( j => fs . statSync ( path . join ( p , j ) ) . isDirectory ( ) )
24+ . map ( j => path . join ( p , j ) )
25+ return tests
26+ } )
27+ }
28+
29+ getAllTests ( ) . map ( tests => {
30+ tests . map ( i => {
31+ console . log ( chalk . green ( `testing: ${ i } ` ) )
32+ const p = require ( path . join ( i , 'package.json' ) )
33+ if ( p . engines && p . engines . node ) {
34+ const currentNodeVersion = process . versions . node
35+ const range = p . engines . node
36+ const engineOk = semver . satisfies ( currentNodeVersion , range )
37+ if ( ! engineOk ) {
38+ console . warn (
39+ chalk . yellow ( `${ i } require Node.js ${ range } , current is ${ currentNodeVersion } , skipping` )
40+ )
41+ return
42+ }
43+ }
44+ const stdout = execSync ( 'npm install' , {
45+ cwd : i
46+ } )
47+ console . log ( stdout . toString ( ) )
48+ } )
49+ } )
You can’t perform that action at this time.
0 commit comments