node-addon-api 3.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/except.gypi +20 -11
- package/napi-inl.h +734 -196
- package/napi.h +420 -164
- package/noexcept.gypi +21 -11
- package/package.json +35 -4
- package/tools/clang-format.js +18 -17
- package/tools/eslint-format.js +71 -0
- package/CHANGELOG.md +0 -722
package/noexcept.gypi
CHANGED
|
@@ -2,15 +2,25 @@
|
|
|
2
2
|
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
|
|
3
3
|
'cflags': [ '-fno-exceptions' ],
|
|
4
4
|
'cflags_cc': [ '-fno-exceptions' ],
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
'conditions': [
|
|
6
|
+
["OS=='win'", {
|
|
7
|
+
# _HAS_EXCEPTIONS is already defined and set to 0 in common.gypi
|
|
8
|
+
#"defines": [
|
|
9
|
+
# "_HAS_EXCEPTIONS=0"
|
|
10
|
+
#],
|
|
11
|
+
"msvs_settings": {
|
|
12
|
+
"VCCLCompilerTool": {
|
|
13
|
+
'ExceptionHandling': 0,
|
|
14
|
+
'EnablePREfast': 'true',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}],
|
|
18
|
+
["OS=='mac'", {
|
|
19
|
+
'xcode_settings': {
|
|
20
|
+
'CLANG_CXX_LIBRARY': 'libc++',
|
|
21
|
+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
|
22
|
+
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
|
23
|
+
},
|
|
24
|
+
}],
|
|
25
|
+
],
|
|
16
26
|
}
|
package/package.json
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"name": "Alba Mendez",
|
|
12
12
|
"url": "https://github.com/jmendeth"
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
"name": "Alexander Floh",
|
|
16
|
+
"url": "https://github.com/alexanderfloh"
|
|
17
|
+
},
|
|
14
18
|
{
|
|
15
19
|
"name": "András Timár, Dr",
|
|
16
20
|
"url": "https://github.com/timarandras"
|
|
@@ -75,6 +79,10 @@
|
|
|
75
79
|
"name": "David Halls",
|
|
76
80
|
"url": "https://github.com/davedoesdev"
|
|
77
81
|
},
|
|
82
|
+
{
|
|
83
|
+
"name": "Deepak Rajamohan",
|
|
84
|
+
"url": "https://github.com/deepakrkris"
|
|
85
|
+
},
|
|
78
86
|
{
|
|
79
87
|
"name": "Dmitry Ashkadov",
|
|
80
88
|
"url": "https://github.com/dmitryash"
|
|
@@ -83,6 +91,10 @@
|
|
|
83
91
|
"name": "Dongjin Na",
|
|
84
92
|
"url": "https://github.com/nadongguri"
|
|
85
93
|
},
|
|
94
|
+
{
|
|
95
|
+
"name": "Doni Rubiagatra",
|
|
96
|
+
"url": "https://github.com/rubiagatra"
|
|
97
|
+
},
|
|
86
98
|
{
|
|
87
99
|
"name": "Ferdinand Holzer",
|
|
88
100
|
"url": "https://github.com/fholzer"
|
|
@@ -275,6 +287,10 @@
|
|
|
275
287
|
"name": "Sam Roberts",
|
|
276
288
|
"url": "https://github.com/sam-github"
|
|
277
289
|
},
|
|
290
|
+
{
|
|
291
|
+
"name": "strager",
|
|
292
|
+
"url": "https://github.com/strager"
|
|
293
|
+
},
|
|
278
294
|
{
|
|
279
295
|
"name": "Taylor Woll",
|
|
280
296
|
"url": "https://github.com/boingoing"
|
|
@@ -291,6 +307,10 @@
|
|
|
291
307
|
"name": "Tobias Nießen",
|
|
292
308
|
"url": "https://github.com/tniessen"
|
|
293
309
|
},
|
|
310
|
+
{
|
|
311
|
+
"name": "todoroff",
|
|
312
|
+
"url": "https://github.com/todoroff"
|
|
313
|
+
},
|
|
294
314
|
{
|
|
295
315
|
"name": "Tux3",
|
|
296
316
|
"url": "https://github.com/tux3"
|
|
@@ -299,6 +319,11 @@
|
|
|
299
319
|
"name": "Vlad Velmisov",
|
|
300
320
|
"url": "https://github.com/Velmisov"
|
|
301
321
|
},
|
|
322
|
+
{
|
|
323
|
+
"name": "WenheLI",
|
|
324
|
+
"url": "https://github.com/WenheLI"
|
|
325
|
+
},
|
|
326
|
+
|
|
302
327
|
{
|
|
303
328
|
"name": "Yohei Kishimoto",
|
|
304
329
|
"url": "https://github.com/morokosi"
|
|
@@ -317,7 +342,14 @@
|
|
|
317
342
|
"benchmark": "^2.1.4",
|
|
318
343
|
"bindings": "^1.5.0",
|
|
319
344
|
"clang-format": "^1.4.0",
|
|
345
|
+
"eslint": "^7.32.0",
|
|
346
|
+
"eslint-config-semistandard": "^16.0.0",
|
|
347
|
+
"eslint-config-standard": "^16.0.3",
|
|
348
|
+
"eslint-plugin-import": "^2.24.2",
|
|
349
|
+
"eslint-plugin-node": "^11.1.0",
|
|
350
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
320
351
|
"fs-extra": "^9.0.1",
|
|
352
|
+
"path": "^0.12.7",
|
|
321
353
|
"pre-commit": "^1.2.2",
|
|
322
354
|
"safe-buffer": "^5.1.1"
|
|
323
355
|
},
|
|
@@ -338,7 +370,6 @@
|
|
|
338
370
|
"license": "MIT",
|
|
339
371
|
"main": "index.js",
|
|
340
372
|
"name": "node-addon-api",
|
|
341
|
-
"optionalDependencies": {},
|
|
342
373
|
"readme": "README.md",
|
|
343
374
|
"repository": {
|
|
344
375
|
"type": "git",
|
|
@@ -359,10 +390,10 @@
|
|
|
359
390
|
"predev:incremental": "node-gyp configure build -C test --debug",
|
|
360
391
|
"dev:incremental": "node test",
|
|
361
392
|
"doc": "doxygen doc/Doxyfile",
|
|
362
|
-
"lint": "node tools/clang-format",
|
|
363
|
-
"lint:fix": "node tools/clang-format --fix"
|
|
393
|
+
"lint": "node tools/eslint-format && node tools/clang-format",
|
|
394
|
+
"lint:fix": "node tools/clang-format --fix && node tools/eslint-format --fix"
|
|
364
395
|
},
|
|
365
396
|
"pre-commit": "lint",
|
|
366
|
-
"version": "3.
|
|
397
|
+
"version": "4.3.0",
|
|
367
398
|
"support": true
|
|
368
399
|
}
|
package/tools/clang-format.js
CHANGED
|
@@ -4,36 +4,35 @@ const spawn = require('child_process').spawnSync;
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
6
|
const filesToCheck = ['*.h', '*.cc'];
|
|
7
|
-
const
|
|
7
|
+
const FORMAT_START = process.env.FORMAT_START || 'main';
|
|
8
8
|
|
|
9
|
-
function main(args) {
|
|
9
|
+
function main (args) {
|
|
10
10
|
let fix = false;
|
|
11
11
|
while (args.length > 0) {
|
|
12
12
|
switch (args[0]) {
|
|
13
13
|
case '-f':
|
|
14
14
|
case '--fix':
|
|
15
15
|
fix = true;
|
|
16
|
+
break;
|
|
16
17
|
default:
|
|
17
18
|
}
|
|
18
19
|
args.shift();
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const clangFormatPath = path.dirname(require.resolve('clang-format'));
|
|
22
23
|
const options = ['--binary=node_modules/.bin/clang-format', '--style=file'];
|
|
23
24
|
if (fix) {
|
|
24
|
-
options.push(
|
|
25
|
+
options.push(FORMAT_START);
|
|
25
26
|
} else {
|
|
26
|
-
options.push('--diff',
|
|
27
|
+
options.push('--diff', FORMAT_START);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
const gitClangFormatPath = path.join(clangFormatPath,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
gitClangFormatPath,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...filesToCheck
|
|
36
|
-
], { encoding: 'utf-8' });
|
|
30
|
+
const gitClangFormatPath = path.join(clangFormatPath, 'bin/git-clang-format');
|
|
31
|
+
const result = spawn(
|
|
32
|
+
'python',
|
|
33
|
+
[gitClangFormatPath, ...options, '--', ...filesToCheck],
|
|
34
|
+
{ encoding: 'utf-8' }
|
|
35
|
+
);
|
|
37
36
|
|
|
38
37
|
if (result.stderr) {
|
|
39
38
|
console.error('Error running git-clang-format:', result.stderr);
|
|
@@ -47,9 +46,11 @@ function main(args) {
|
|
|
47
46
|
return 0;
|
|
48
47
|
}
|
|
49
48
|
// Detect if there is any complains from clang-format
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (
|
|
50
|
+
clangFormatOutput !== '' &&
|
|
51
|
+
clangFormatOutput !== 'no modified files to format' &&
|
|
52
|
+
clangFormatOutput !== 'clang-format did not modify any files'
|
|
53
|
+
) {
|
|
53
54
|
console.error(clangFormatOutput);
|
|
54
55
|
const fixCmd = 'npm run lint:fix';
|
|
55
56
|
console.error(`
|
|
@@ -57,7 +58,7 @@ function main(args) {
|
|
|
57
58
|
Note that when running the command locally, please keep your local
|
|
58
59
|
main branch and working branch up to date with nodejs/node-addon-api
|
|
59
60
|
to exclude un-related complains.
|
|
60
|
-
Or you can run "env
|
|
61
|
+
Or you can run "env FORMAT_START=upstream/main ${fixCmd}".`);
|
|
61
62
|
return 1;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const spawn = require('child_process').spawnSync;
|
|
4
|
+
|
|
5
|
+
const filesToCheck = '*.js';
|
|
6
|
+
const FORMAT_START = process.env.FORMAT_START || 'main';
|
|
7
|
+
|
|
8
|
+
function main (args) {
|
|
9
|
+
let fix = false;
|
|
10
|
+
while (args.length > 0) {
|
|
11
|
+
switch (args[0]) {
|
|
12
|
+
case '-f':
|
|
13
|
+
case '--fix':
|
|
14
|
+
fix = true;
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
}
|
|
18
|
+
args.shift();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Check js files that change on unstaged file
|
|
22
|
+
const fileUnStaged = spawn(
|
|
23
|
+
'git',
|
|
24
|
+
['diff', '--name-only', FORMAT_START, filesToCheck],
|
|
25
|
+
{
|
|
26
|
+
encoding: 'utf-8'
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Check js files that change on staged file
|
|
31
|
+
const fileStaged = spawn(
|
|
32
|
+
'git',
|
|
33
|
+
['diff', '--name-only', '--cached', FORMAT_START, filesToCheck],
|
|
34
|
+
{
|
|
35
|
+
encoding: 'utf-8'
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const options = [
|
|
40
|
+
...fileStaged.stdout.split('\n').filter((f) => f !== ''),
|
|
41
|
+
...fileUnStaged.stdout.split('\n').filter((f) => f !== '')
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
if (fix) {
|
|
45
|
+
options.push('--fix');
|
|
46
|
+
}
|
|
47
|
+
const result = spawn('node_modules/.bin/eslint', [...options], {
|
|
48
|
+
encoding: 'utf-8'
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (result.status === 1) {
|
|
52
|
+
console.error('Eslint error:', result.stdout);
|
|
53
|
+
const fixCmd = 'npm run lint:fix';
|
|
54
|
+
console.error(`ERROR: please run "${fixCmd}" to format changes in your commit
|
|
55
|
+
Note that when running the command locally, please keep your local
|
|
56
|
+
main branch and working branch up to date with nodejs/node-addon-api
|
|
57
|
+
to exclude un-related complains.
|
|
58
|
+
Or you can run "env FORMAT_START=upstream/main ${fixCmd}".
|
|
59
|
+
Also fix JS files by yourself if necessary.`);
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (result.stderr) {
|
|
64
|
+
console.error('Error running eslint:', result.stderr);
|
|
65
|
+
return 2;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (require.main === module) {
|
|
70
|
+
process.exitCode = main(process.argv.slice(2));
|
|
71
|
+
}
|