Browse Source

Formatting for cert expiration time

master
Olli Vanhoja 8 years ago
parent
commit
c75b9adcc0
  1. 7
      bin/now-certs

7
bin/now-certs

@ -95,6 +95,11 @@ if (argv.help || !subcommand) {
});
}
function formatExpirationDate (date) {
const diff = date - Date.now();
return diff < 0 ? chalk.gray(ms(new Date(-expDiff)) + ' ago') : chalk.gray('in ' + ms(new Date(diff)));
}
async function run (token) {
const certs = new NowCerts(apiUrl, token, { debug });
const args = argv._.slice(1);
@ -116,7 +121,7 @@ async function run (token) {
const out = table(header.concat(list.map((cert) => {
const cn = chalk.bold(cert.cn);
const time = chalk.gray(ms(cur - new Date(cert.created)) + ' ago');
const expiration = chalk.gray(new Date(cert.expiration));
const expiration = formatExpirationDate(new Date(cert.expiration));
return [
'',
cert.uid ? cert.uid : 'unknown',

Loading…
Cancel
Save