Skip to content

Commit

Permalink
Proper strlen function for strings containing ANSI escape codes
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliV committed Oct 20, 2016
1 parent c75b9ad commit b6f1354
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/now-alias
Expand Up @@ -2,6 +2,7 @@
import chalk from 'chalk';
import minimist from 'minimist';
import table from 'text-table';
import strlen from '../lib/strlen';
import ms from 'ms';
import NowAlias from '../lib/alias';
import login from '../lib/login';
Expand Down Expand Up @@ -142,7 +143,7 @@ async function run (token) {
_url,
time
];
}), { align: ['l', 'r', 'l', 'l'], hsep: ' '.repeat(2) });
}), { align: ['l', 'r', 'l', 'l'], hsep: ' '.repeat(2), stringLength: strlen });

const elapsed_ = ms(new Date() - start_);
console.log(`> ${aliases.length} alias${aliases.length > 1 ? 'es' : ''} found ${chalk.gray(`[${elapsed_}]`)}`);
Expand Down
3 changes: 2 additions & 1 deletion bin/now-list
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs-promise';
import minimist from 'minimist';
import chalk from 'chalk';
import table from 'text-table';
import strlen from '../lib/strlen';
import ms from 'ms';
import Now from '../lib';
import login from '../lib/login';
Expand Down Expand Up @@ -101,7 +102,7 @@ async function list (token) {
const _url = chalk.underline(`https://${url}`);
const time = chalk.gray(ms(current - created) + ' ago');
return [uid, _url, time];
}), { align: ['l', 'r', 'l'], hsep: ' '.repeat(6) });
}), { align: ['l', 'r', 'l'], hsep: ' '.repeat(6), stringLength: strlen });
return chalk.bold(name) + '\n\n' + indent(t, 2);
}).join('\n\n');
const elapsed = ms(new Date() - start);
Expand Down
3 changes: 2 additions & 1 deletion bin/now-secrets
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import chalk from 'chalk';
import table from 'text-table';
import strlen from '../lib/strlen';
import minimist from 'minimist';
import * as cfg from '../lib/cfg';
import { handleError, error } from '../lib/error';
Expand Down Expand Up @@ -119,7 +120,7 @@ async function run (token) {
chalk.bold(secret.name),
chalk.gray(ms(cur - new Date(secret.created)) + ' ago')
];
}), { align: ['l', 'r', 'l'], hsep: ' '.repeat(2) });
}), { align: ['l', 'r', 'l'], hsep: ' '.repeat(2), stringLength: strlen });
if (out) console.log('\n' + out + '\n');
return secrets.close();
}
Expand Down

0 comments on commit b6f1354

Please sign in to comment.