Skip to content

Commit

Permalink
v6.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Mar 10, 2020
1 parent 26f7655 commit c73bb33
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "nodemailer",
"version": "6.4.4",
"version": "6.4.5",
"description": "Easy as cake e-mail sending from your Node.js applications",
"main": "lib/nodemailer.js",
"scripts": {
"test": "grunt"
"test": "grunt",
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,7 +36,7 @@
"nodemailer-ntlm-auth": "1.0.1",
"proxy": "1.0.1",
"proxy-test-server": "1.0.0",
"sinon": "9.0.0",
"sinon": "9.0.1",
"smtp-server": "3.5.0"
},
"engines": {
Expand Down
58 changes: 58 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint no-control-regex:0 */
'use strict';

const packageData = require('./package.json');
const isEnabled = value => !!value && value !== '0' && value !== 'false';
const canUseColor = isEnabled(process.env.npm_config_color);

const text = `=== Nodemailer ${packageData.version} ===
Thank you for using Nodemailer for your email sending needs! While Nodemailer itself is mostly meant to be a SMTP client there are other related projects in the Nodemailer project as well.
For example:
> IMAP API ( https://imapapi.com ) is a server application to easily access IMAP accounts via REST API
> NodemailerApp ( https://nodemailer.com/app/ ) is a cross platform GUI app to debug emails
`;

const formatRow = (row, columns) => {
if (row.length <= columns) {
return [row];
}
// wrap!
let lines = [];
while (row.length) {
if (row.length <= columns) {
lines.push(row);
break;
}
let slice = row.substr(0, columns);

let match = slice.match(/(\s+)[^\s]*$/);
if (match && match.index) {
let line = row.substr(0, match.index);
row = row.substr(line.length + match[1].length);
lines.push(line);
} else {
lines.push(row);
break;
}
}
return lines;
};

const wrapText = text => {
let columns = Number(process.stdout.columns) || 80;
columns = Math.min(columns, 80) - 1;

return text
.split('\n')
.flatMap(row => formatRow(row, columns))
.join('\n');
};

const banner = wrapText(text)
.replace(/^/gm, '\u001B[96m')
.replace(/$/gm, '\u001B[0m')
.replace(/(https:[^\s)]+)/g, '\u001B[94m $1 \u001B[96m');

console.log(canUseColor ? banner : banner.replace(/\u001B\[\d+m/g, ''));

0 comments on commit c73bb33

Please sign in to comment.