diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..30ddbbb --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.js text eol=lf \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06bcc68..e7be683 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/lib/smtp-connection.js b/lib/smtp-connection.js index dcfc0b3..a8fc2f2 100644 --- a/lib/smtp-connection.js +++ b/lib/smtp-connection.js @@ -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; } diff --git a/lib/smtp-stream.js b/lib/smtp-stream.js index 83502d3..b7c2a9a 100755 --- a/lib/smtp-stream.js +++ b/lib/smtp-stream.js @@ -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. */ @@ -107,7 +94,7 @@ class SMTPStream extends Writable { next(...args); }; - if (this.closed) { + if (this.isClosed) { return done(); } @@ -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')); diff --git a/package.json b/package.json index 725778a..22c557d 100644 --- a/package.json +++ b/package.json @@ -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": {