mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-10-12 02:42:27 +07:00
node_modules: update (#344)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
1 parent
b099186883
commit
6e88c72525
63 files changed
+2863
-1227
No files matched your search
+54
-14
@@ -37,11 +37,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const node_child_process_1 = require("node:child_process");
|
||||
const node_stream_1 = require("node:stream");
|
||||
const packageData = __importStar(require("../package-info.js"));
|
||||
const shared = __importStar(require("../shared/index.js"));
|
||||
const errors = __importStar(require("../errors.js"));
|
||||
const le_windows_js_1 = __importDefault(require("../mime-node/le-windows.js"));
|
||||
const le_unix_js_1 = __importDefault(require("../mime-node/le-unix.js"));
|
||||
// how long an stdin error waits for the exit code of the process before it is reported
|
||||
const STDIN_ERROR_EXIT_WAIT = 1000;
|
||||
/**
|
||||
* Generates a Transport object for Sendmail
|
||||
*
|
||||
@@ -139,37 +142,75 @@ class SendmailTransport {
|
||||
return callback(E);
|
||||
}
|
||||
if (sendmail) {
|
||||
let stream;
|
||||
// ended once the whole message was handed to stdin
|
||||
const messageWritten = () => !!stream && stream.readableEnded;
|
||||
// an EPIPE says less than the exit code that usually follows it, so it is only
|
||||
// reported when the process exits without one
|
||||
let stdinError = null;
|
||||
// releases whatever the message is still being read from
|
||||
const release = () => {
|
||||
if (stream && !messageWritten()) {
|
||||
stream.destroy();
|
||||
}
|
||||
};
|
||||
const fail = (err) => {
|
||||
release();
|
||||
callback(err);
|
||||
};
|
||||
sendmail.on('error', err => {
|
||||
this.logger.error({
|
||||
err,
|
||||
tnx: 'spawn',
|
||||
messageId
|
||||
}, 'Error occurred when sending message %s. %s', messageId, err.message);
|
||||
callback(err);
|
||||
fail(err);
|
||||
});
|
||||
sendmail.once('exit', code => {
|
||||
if (!code) {
|
||||
// 'close' follows 'exit' with the same arguments, it is only listened to in case the
|
||||
// process ends without an 'exit' event
|
||||
const onExit = (code, signal) => {
|
||||
let err = null;
|
||||
if (code) {
|
||||
err = new Error(code === 127 ? 'Sendmail command not found, process exited with code ' + code : 'Sendmail exited with code ' + code);
|
||||
}
|
||||
else if (signal) {
|
||||
err = new Error('Sendmail was terminated by ' + signal);
|
||||
}
|
||||
else if (!messageWritten()) {
|
||||
// exiting with 0 before the message was written does not mean it was queued
|
||||
err = new Error('Sendmail exited before the message was written');
|
||||
}
|
||||
else if (stdinError) {
|
||||
err = stdinError;
|
||||
}
|
||||
if (!err) {
|
||||
return callback();
|
||||
}
|
||||
const err = new Error(code === 127 ? 'Sendmail command not found, process exited with code ' + code : 'Sendmail exited with code ' + code);
|
||||
err.code = errors.ESENDMAIL;
|
||||
err.code = err.code || errors.ESENDMAIL;
|
||||
this.logger.error({
|
||||
err,
|
||||
tnx: 'stdin',
|
||||
messageId
|
||||
}, 'Error sending message %s to sendmail. %s', messageId, err.message);
|
||||
callback(err);
|
||||
});
|
||||
// the close listener is handed the exit code as its first argument, so a non-zero
|
||||
// code reaching it before the exit listener did counts as the error value
|
||||
sendmail.once('close', callback);
|
||||
fail(err);
|
||||
};
|
||||
sendmail.once('exit', onExit);
|
||||
sendmail.once('close', onExit);
|
||||
sendmail.stdin.on('error', err => {
|
||||
this.logger.error({
|
||||
err,
|
||||
tnx: 'stdin',
|
||||
messageId
|
||||
}, 'Error occurred when piping message %s to sendmail. %s', messageId, err.message);
|
||||
callback(err);
|
||||
if (stdinError) {
|
||||
return;
|
||||
}
|
||||
stdinError = err;
|
||||
release();
|
||||
// a process that closed its stdin normally exits right after, with a code that
|
||||
// tells more than the EPIPE. Report the EPIPE if it does not
|
||||
const exitTimer = setTimeout(() => fail(err), STDIN_ERROR_EXIT_WAIT);
|
||||
sendmail.once('exit', () => clearTimeout(exitTimer));
|
||||
});
|
||||
const recipients = [].concat(envelope.to || []);
|
||||
if (recipients.length > 3) {
|
||||
@@ -180,12 +221,11 @@ class SendmailTransport {
|
||||
messageId
|
||||
}, 'Sending message %s to <%s>', messageId, recipients.join(', '));
|
||||
const sourceStream = mail.message.createReadStream();
|
||||
let stream = sourceStream;
|
||||
stream = sourceStream;
|
||||
if (this.options.newline) {
|
||||
// apply the transport-level line ending transform; the message-level
|
||||
// `newline` option is handled by MimeNode in createReadStream()
|
||||
stream = sourceStream.pipe(this.winbreak ? new le_windows_js_1.default() : new le_unix_js_1.default());
|
||||
sourceStream.once('error', err => stream.emit('error', err));
|
||||
stream = (0, node_stream_1.pipeline)(sourceStream, this.winbreak ? new le_windows_js_1.default() : new le_unix_js_1.default(), () => false);
|
||||
}
|
||||
stream.once('error', err => {
|
||||
this.logger.error({
|
||||
|
||||
Reference in new issue
Block a user