8000 fixes UT bug. · VictorKostyukov/leetcode-cli@168b0f4 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 168b0f4

Browse files
committed
fixes UT bug.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent aaf6451 commit 168b0f4

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

lib/commands/stat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function showGraph(problems) {
104104
for (let problem of problems)
105105
graph[problem.fid] = ICONS[problem.state] || ICONS.none;
106106

107-
let line = [sprintf('%04s', 0)];
107+
let line = [sprintf(' %03s', 0)];
108108
for (let i = 1, n = graph.length; i <= n; ++i) {
109109
// padding before group
110110
if (i % 10 === 1) line.push(' ');
@@ -114,7 +114,7 @@ function showGraph(problems) {
114114
// time to start new row
115115
if (i % (10 * groups) === 0 || i === n) {
116116
log.info(line.join(' '));
117-
line = [sprintf('%04s', i)];
117+
line = [sprintf(' %03s', i)];
118118
}
119119
}
120120

lib/commands/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cmd.handler = function(argv) {
4747
'| | ___ ___| |_ ___ ___ __| | ___ ',
4848
'| |/ _ \\/ _ \\ __|/ __|/ _ \\ / _` |/ _ \\',
4949
'| | __/ __/ |_ (__| (_) | (_| | __/',
50-
'|_|\\___|\\___|\\__|\\___|\\___/ \\__,_|\\___| CLI v' + version
50+
'|_|\\___|\\___|\\__|\\___|\\___/ \\__,_|\\___| CLI ' + chalk.green('v' + version)
5151
].join('\n');
5252
log.info(logo);
5353

lib/sprintf.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const tsprintf = function() {
4242
n = parseInt(s.slice(1)) || 0;
4343
x = padCenter(x, n, ' ');
4444
break;
45+
case '0':
46+
n = parseInt(s.slice(1)) || 0;
47+
x = padLeft(x, n, '0');
48+
break;
4549
default:
4650
n = parseInt(s) || 0;
4751
x = padLeft(x, n, ' ');

test/test_sprintf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('sprintf', function() {
99
assert.equal(sprintf('%%'), '%');
1010
assert.equal(sprintf('%s', 123), '123');
1111
assert.equal(sprintf('%6s', 123), ' 123');
12+
assert.equal(sprintf('%06s', 123), '000123');
1213
assert.equal(sprintf('%-6s', 123), '123 ');
1314
assert.equal(sprintf('%=6s', 123), ' 123 ');
1415

@@ -26,8 +27,7 @@ describe('sprintf', function() {
2627
it('should color ok', function() {
2728
const chalk = rewire('../lib/chalk');
2829
chalk.init();
29-
chalk.setTheme('default');
3030

31-
assert.equal(sprintf('%=3s', chalk.red('X')), ' \u001b[38;5;196mX\u001b[39m ');
31+
assert.equal(sprintf('%=3s', chalk.red('X')), ' ' + chalk.red('X') + ' ');
3232
});
3333
});

0 commit comments

Comments
 (0)
0