Skip to content

Commit

Permalink
renamed .closed to .isClosed
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Apr 28, 2022
1 parent a2e765f commit 2bd0975
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js text eol=lf
43 changes: 19 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
on: push
name: Run tests

jobs:
test:
name: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [^12, ^14, ^16, ^18]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: checkout
uses: actions/checkout@v2

- name: node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
on:
push:
pull_request:

- name: install
run: npm install

- name: test
run: npm test
jobs:
test:
strategy:
matrix:
node: [12.x, 14.x, 16.x, 18.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
5 changes: 1 addition & 4 deletions lib/smtp-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ class SMTPConnection extends EventEmitter {
*/
_onClose(/* hadError */) {
if (this._parser) {
// node 18 makes this a getter-only property, handled internally
if (this._parser.canSetClosedProp) {
this._parser.closed = true;
}
this._parser.isClosed = true;
this._socket.unpipe(this._parser);
this._parser = false;
}
Expand Down
19 changes: 3 additions & 16 deletions lib/smtp-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,12 @@ class SMTPStream extends Writable {
// unprocessed bytes from the last parsing iteration (used in data mode)
this._lastBytes = false;

// node 18 makes this a getter-only property, handled internally
if (this.canSetClosedProp) {
this.closed = false;
}
this.isClosed = false;

// once the input stream ends, flush all output without expecting the newline
this.on('finish', () => this._flushData());
}

get canSetClosedProp() {
try {
const { closed } = this;
this.closed = closed;
return true;
} catch (err) {
return false;
}
}

/**
* Placeholder command handler. Override this with your own.
*/
Expand Down Expand Up @@ -107,7 +94,7 @@ class SMTPStream extends Writable {
next(...args);
};

if (this.closed) {
if (this.isClosed) {
return done();
}

Expand Down Expand Up @@ -245,7 +232,7 @@ class SMTPStream extends Writable {
*/
_flushData() {
let line;
if (this._remainder && !this.closed) {
if (this._remainder && !this.isClosed) {
line = this._remainder;
this._remainder = '';
this.oncommand(Buffer.from(line, 'binary'));
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"dependencies": {
"base32.js": "0.1.0",
"ipv6-normalize": "1.0.1",
"nodemailer": "6.7.2"
"nodemailer": "6.7.3"
},
"devDependencies": {
"chai": "4.3.6",
"eslint-config-nodemailer": "1.2.0",
"eslint-config-prettier": "8.4.0",
"grunt": "1.4.1",
"eslint-config-prettier": "8.5.0",
"grunt": "1.5.2",
"grunt-cli": "1.4.3",
"grunt-eslint": "24.0.0",
"grunt-mocha-test": "0.13.3",
"mocha": "9.2.1",
"mocha": "9.2.2",
"pem": "1.14.6"
},
"repository": {
Expand Down

0 comments on commit 2bd0975

Please sign in to comment.