Skip to content

Commit b1fdda4

Browse files
kkocdkodeepak1556
andauthored
Port to NAPI (microsoft#644)
* Port to NAPI The "5th pty bug" in microsoft#432 fixed also. * Fix help message in pty.cc * Move NAPI deps to devDependencies in package.json * Apply most of deepak1556's suggestions * Fix winpty * Fix conpty missing CloseHandle * Use unique_ptr to avoid `goto`s * Why macos failed? * fix: ci and minor cleanups * fix build failed on windows --------- Co-authored-by: deepak1556 <hop2deep@gmail.com>
1 parent d6ce76a commit b1fdda4

10 files changed

Lines changed: 543 additions & 651 deletions

File tree

azure-pipelines.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
inputs:
4343
versionSpec: $(node_version)
4444
displayName: 'Install Node.js'
45+
- script: |
46+
python3 -m pip install setuptools
47+
displayName: Install setuptools (macOS)
4548
- script: |
4649
npm i
4750
displayName: 'Install dependencies and build'
@@ -54,7 +57,7 @@ jobs:
5457
5558
- job: Windows
5659
pool:
57-
vmImage: 'windows-2019'
60+
vmImage: 'windows-latest'
5861
strategy:
5962
matrix:
6063
node_16_x:
@@ -87,7 +90,7 @@ jobs:
8790
steps:
8891
- task: NodeTool@0
8992
inputs:
90-
versionSpec: '16.x'
93+
versionSpec: '18.x'
9194
displayName: 'Install Node.js'
9295
- script: |
9396
npm i

binding.gyp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
'target_defaults': {
3+
'dependencies': [
4+
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
5+
],
36
'conditions': [
47
['OS=="win"', {
58
'msvs_configuration_attributes': {
@@ -28,9 +31,6 @@
2831
'targets': [
2932
{
3033
'target_name': 'conpty',
31-
'include_dirs' : [
32-
'<!(node -e "require(\'nan\')")'
33-
],
3434
'sources' : [
3535
'src/win/conpty.cc',
3636
'src/win/path_util.cc'
@@ -41,17 +41,14 @@
4141
},
4242
{
4343
'target_name': 'conpty_console_list',
44-
'include_dirs' : [
45-
'<!(node -e "require(\'nan\')")'
46-
],
4744
'sources' : [
4845
'src/win/conpty_console_list.cc'
4946
],
5047
},
5148
{
5249
'target_name': 'pty',
5350
'include_dirs' : [
54-
'<!(node -e "require(\'nan\')")',
51+
'<!(node -p "require(\'node-addon-api\').include_dir")',
5552
'deps/winpty/src/include',
5653
],
5754
# Disabled due to winpty
@@ -73,9 +70,6 @@
7370
'targets': [
7471
{
7572
'target_name': 'pty',
76-
'include_dirs' : [
77-
'<!(node -e "require(\'nan\')")'
78-
],
7973
'sources': [
8074
'src/unix/pty.cc',
8175
],
@@ -91,11 +85,6 @@
9185
'libraries!': [
9286
'-lutil'
9387
]
94-
}],
95-
['OS=="mac"', {
96-
"xcode_settings": {
97-
"MACOSX_DEPLOYMENT_TARGET":"10.7"
98-
}
9988
}]
10089
]
10190
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"prepublishOnly": "npm run build"
4444
},
4545
"dependencies": {
46-
"nan": "^2.17.0"
46+
"node-addon-api": "^7.1.0"
4747
},
4848
"devDependencies": {
4949
"@types/mocha": "^7.0.2",

0 commit comments

Comments
 (0)