Skip to content

Commit 4c39024

Browse files
committed
fix: Compatible with Node 12.3.0 and higher versions. (#378)
(cherry picked from commit 2d659d2)
1 parent 262918a commit 4c39024

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
The Pulsar Node.js client can be used to create Pulsar producers and consumers in Node.js. For the supported Pulsar features, see [Client Feature Matrix](https://pulsar.apache.org/client-feature-matrix/).
2525

26-
This library works only in Node.js 10.x or later because it uses the
27-
[node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.
26+
This library works only in Node.js 12.3 or later because it uses:
27+
1. The [node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.
28+
2. The [Mozilla CA](https://nodejs.org/api/tls.html#tlsrootcertificates) file, which is provided by Node.js v12.3.0 and subsequent versions.
2829

2930
## Getting Started
3031

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"license": "Apache-2.0",
3333
"gypfile": true,
3434
"engines": {
35-
"node": ">=10.16.0"
35+
"node": ">=12.3.0"
3636
},
3737
"devDependencies": {
3838
"@seadub/clang-format-lint": "0.0.2",

src/Client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ class Client {
5757
}
5858

5959
static genCertFile() {
60-
fs.rmSync(certsFilePath, { force: true });
60+
try {
61+
if (fs.existsSync(certsFilePath)) {
62+
fs.unlinkSync(certsFilePath);
63+
}
64+
} catch (err) {
65+
console.error(err);
66+
}
67+
6168
const fd = fs.openSync(certsFilePath, 'a');
6269
try {
6370
tls.rootCertificates.forEach((cert) => {

0 commit comments

Comments
 (0)