Skip to content

Commit 865fb98

Browse files
committed
Port project to N-API
1 parent b4d5122 commit 865fb98

File tree

10 files changed

+528
-474
lines changed

10 files changed

+528
-474
lines changed

binding.gyp

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
'targets': [
55
{
66
'target_name': 'conpty',
7+
'cflags!': [ '-fno-exceptions' ],
8+
'cflags_cc!': [ '-fno-exceptions' ],
9+
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
10+
'CLANG_CXX_LIBRARY': 'libc++',
11+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
12+
},
13+
'msvs_settings': {
14+
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
15+
},
716
'include_dirs' : [
8-
'<!(node -e "require(\'nan\')")'
17+
'<!(node -p "require(\'node-addon-api\').include_dir")'
918
],
1019
'sources' : [
1120
'src/win/conpty.cc',
@@ -17,17 +26,35 @@
1726
},
1827
{
1928
'target_name': 'conpty_console_list',
29+
'cflags!': [ '-fno-exceptions' ],
30+
'cflags_cc!': [ '-fno-exceptions' ],
31+
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
32+
'CLANG_CXX_LIBRARY': 'libc++',
33+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
34+
},
35+
'msvs_settings': {
36+
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
37+
},
2038
'include_dirs' : [
21-
'<!(node -e "require(\'nan\')")'
39+
'<!(node -p "require(\'node-addon-api\').include_dir")'
2240
],
2341
'sources' : [
2442
'src/win/conpty_console_list.cc'
2543
]
2644
},
2745
{
2846
'target_name': 'pty',
47+
'cflags!': [ '-fno-exceptions' ],
48+
'cflags_cc!': [ '-fno-exceptions' ],
49+
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
50+
'CLANG_CXX_LIBRARY': 'libc++',
51+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
52+
},
53+
'msvs_settings': {
54+
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
55+
},
2956
'include_dirs' : [
30-
'<!(node -e "require(\'nan\')")',
57+
'<!(node -p "require(\'node-addon-api\').include_dir")',
3158
'deps/winpty/src/include',
3259
],
3360
# Disabled due to winpty
@@ -48,8 +75,17 @@
4875
}, { # OS!="win"
4976
'targets': [{
5077
'target_name': 'pty',
78+
'cflags!': [ '-fno-exceptions' ],
79+
'cflags_cc!': [ '-fno-exceptions' ],
80+
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
81+
'CLANG_CXX_LIBRARY': 'libc++',
82+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
83+
},
84+
'msvs_settings': {
85+
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
86+
},
5187
'include_dirs' : [
52-
'<!(node -e "require(\'nan\')")'
88+
'<!(node -p "require(\'node-addon-api\').include_dir")'
5389
],
5490
'sources': [
5591
'src/unix/pty.cc'
@@ -67,6 +103,7 @@
67103
]
68104
}],
69105
['OS=="mac"', {
106+
"cflags+": ["-fvisibility=hidden"],
70107
"xcode_settings": {
71108
"OTHER_CPLUSPLUSFLAGS": [
72109
"-std=c++11",
@@ -75,7 +112,8 @@
75112
"OTHER_LDFLAGS": [
76113
"-stdlib=libc++"
77114
],
78-
"MACOSX_DEPLOYMENT_TARGET":"10.7"
115+
"MACOSX_DEPLOYMENT_TARGET":"10.7",
116+
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES", # -fvisibility=hidden
79117
}
80118
}]
81119
]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"prepublishOnly": "npm run build"
4545
},
4646
"dependencies": {
47-
"nan": "^2.14.0"
47+
"node-addon-api": "^3.0.2"
4848
},
4949
"devDependencies": {
5050
"@types/mocha": "^7.0.2",

src/terminal.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ describe('Terminal', () => {
8585
assert.equal(pty.handleFlowControl, true);
8686
assert.equal((pty as any)._flowControlPause, 'abc');
8787
assert.equal((pty as any)._flowControlResume, '123');
88+
pty.kill();
8889
});
8990
// TODO: I don't think this test ever worked due to pollUntil being used incorrectly
9091
// it('should do flow control automatically', async function(): Promise<void> {

0 commit comments

Comments
 (0)