Skip to content

Commit 6e7652b

Browse files
committed
works on Windows, and kinda on iTerm
1 parent 37617be commit 6e7652b

File tree

5 files changed

+57
-43
lines changed

5 files changed

+57
-43
lines changed

lib/reporters/mini.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var lastLineStream = require('last-line-stream');
55
var plur = require('plur');
66
var colors = require('../colors');
77
var beautifyStack = require('../beautify-stack');
8+
var isWindows = require('os').platform() === 'win32';
89

910
function MiniReporter() {
1011
if (!(this instanceof MiniReporter)) {
@@ -154,9 +155,14 @@ MiniReporter.prototype._clear = function () {
154155
return '';
155156
}
156157
var lastLine = this.stream.lastLine;
158+
var len = lastLine.length;
157159
var columns = process.stdout.columns;
158-
while (lastLine.length > columns) {
159-
lastLine = lastLine.substr(columns);
160+
lastLine = lastLine.substring(len - (len % columns));
161+
if (!lastLine.length) {
162+
if (isWindows || !len) {
163+
ct++;
164+
}
165+
return ansiEscapes.eraseLines(ct);
160166
}
161167
return ansiEscapes.eraseLines(ct + 1) + lastLine;
162168
};

test/visual/lorem-ipsum.js

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,13 @@
11
'use strict';
2-
3-
var fs = require('fs');
4-
var path = require('path');
5-
var text = fs.readFileSync(path.join(__dirname, 'lorem-ipsum.txt'), 'utf8');
62
var test = require('../../');
73
var delay = require('delay');
8-
9-
var lines = text.split(/\r?\n/g).map(function (line) {
10-
return line.split(' ');
11-
});
12-
13-
setTimeout(function () {
14-
var lineNum = 0;
15-
var wordNum = 0;
16-
17-
var interval = setInterval(function () {
18-
if (lineNum >= lines.length) {
19-
clearInterval(interval);
20-
return;
21-
}
22-
var line = lines[lineNum];
23-
if (wordNum >= line.length) {
24-
process.stdout.write('\n');
25-
lineNum++;
26-
wordNum = 0;
27-
return;
28-
}
29-
var word = line[wordNum];
30-
wordNum++;
31-
if (wordNum < line.length) {
32-
word += ' ';
33-
}
34-
process.stdout.write(word);
35-
}, 50);
36-
}, 200);
4+
require('./print-lorem-ipsum');
375

386
async function testFn(t) {
397
await delay(40);
408
t.pass();
419
}
4210

43-
for (var i = 0; i < 250; i++) {
11+
for (var i = 0; i < 350; i++) {
4412
test.serial('test number ' + i, testFn);
4513
}

test/visual/lorem-ipsum.txt

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
Lorem ipsum dolor sit amet, est ut alia vitae, commune appetere fabellas et sea, id diam error iisque eum. Has legendos adipiscing ad. Mea everti audiam te. Ne est legendos qualisque, id fabulas nominati eos, vim an magna praesent. Cum eu eius conclusionemque, paulo iudico populo vix eu, dicunt aperiri abhorreant ad est.
1+
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
22

3-
Suas constituam sit ea, populo moderatius eam ei. Ei melius nonumes invidunt vim, duo minim veniam cu. Omnis maiorum nam no, eu his choro dolorem disputando. Vel te lorem mandamus, sed in prompta electram. Nam id omnium mandamus erroribus, ut eos duis etiam perfecto.
3+
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
44

5-
Qui viris euripidis eloquentiam ut. Eam vide disputando ei, pro no partiendo iracundia, ne sed vocibus graecis. Mel id saepe iracundia philosophia, oratio rationibus te vel. Ad delicata assentior vel, cu sit dicit deseruisse, ne aliquip propriae concludaturque est.
6-
7-
Ipsum munere neglegentur an est. Mundi aliquid delenit ei duo, duis fabellas reformidans pro te. An soluta copiosae indoctum cum. Ut his menandri suavitate.
8-
9-
Alia laoreet pri id. Per solum lorem percipit te, eu diam modus iusto vel, id pro primis noster quaestio. Quot choro lucilius cum no. Nobis alterum habemus duo no. Scripta regione eloquentiam ad eam, ad sonet sententiae pro.
5+
But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.

test/visual/print-lorem-ipsum.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
var fs = require('fs');
3+
var path = require('path');
4+
var text = fs.readFileSync(path.join(__dirname, 'lorem-ipsum.txt'), 'utf8');
5+
6+
var lines = text.split(/\r?\n/g).map(function (line) {
7+
return line.split(' ');
8+
});
9+
10+
setTimeout(function () {
11+
var lineNum = 0;
12+
var wordNum = 0;
13+
14+
var interval = setInterval(function () {
15+
if (lineNum >= lines.length) {
16+
clearInterval(interval);
17+
return;
18+
}
19+
var line = lines[lineNum];
20+
if (wordNum >= line.length) {
21+
process.stdout.write('\n');
22+
lineNum++;
23+
wordNum = 0;
24+
return;
25+
}
26+
var word = line[wordNum];
27+
wordNum++;
28+
if (wordNum < line.length) {
29+
word += ' ';
30+
}
31+
process.stdout.write(word);
32+
}, 50);
33+
}, 200);
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import test from '../../'
2+
3+
4+
function writeline() {
5+
for (var i = 0; i < 80; i++) {
6+
process.stdout.write(String(i % 10))
7+
}
8+
}
9+
10+
test.serial(t=>{writeline(),t.pass()});
11+
test.serial(t=>{writeline(),t.pass()});

0 commit comments

Comments
 (0)