Skip to content

Commit 23d55c4

Browse files
committed
[Fix] Check intercepted text is string
1 parent c098118 commit 23d55c4

File tree

11 files changed

+80
-60
lines changed

11 files changed

+80
-60
lines changed

test/Commands/testInit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ module.exports = {
9696
bddStdin(userInput.shift());
9797

9898
unhookIntercept = intercept(function onIntercept(txt) {
99-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
100-
// return '';
99+
if (typeof txt === 'string') {
100+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
101+
}
101102
});
102103
app.init({
103104
chdir: appdir + '/'

test/Commands/testLaravelConfig.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ module.exports = {
100100
fs: fsMock
101101
});
102102
var unhookIntercept = intercept(function onIntercept(txt) {
103-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
104-
// return '';
103+
if (typeof txt === 'string') {
104+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
105+
}
105106
});
106107
app.init({
107108
chdir: appdir + '/'
@@ -151,8 +152,9 @@ module.exports = {
151152
shelljs: shelljsMock
152153
});
153154
var unhookIntercept = intercept(function onIntercept(txt) {
154-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
155-
// return '';
155+
if (typeof txt === 'string') {
156+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
157+
}
156158
});
157159
app.init({
158160
chdir: appdir + '/'
@@ -191,8 +193,9 @@ module.exports = {
191193
tmp: tmpMock
192194
});
193195
var unhookIntercept = intercept(function onIntercept(txt) {
194-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
195-
// return '';
196+
if (typeof txt === 'string') {
197+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
198+
}
196199
});
197200
app.init({
198201
chdir: appdir + '/'
@@ -233,8 +236,9 @@ module.exports = {
233236
shelljs: shelljsMock
234237
});
235238
var unhookIntercept = intercept(function onIntercept(txt) {
236-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
237-
// return '';
239+
if (typeof txt === 'string') {
240+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
241+
}
238242
});
239243
app.init({
240244
chdir: appdir + '/'
@@ -266,8 +270,9 @@ module.exports = {
266270
bddStdin('\n', 'y\n', 'n\n');
267271
process.argv = ['node', appdir + '/artisan', 'laravel:config'];
268272
var unhookIntercept = intercept(function onIntercept(txt) {
269-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
270-
// return '';
273+
if (typeof txt === 'string') {
274+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
275+
}
271276
});
272277
app.init({
273278
chdir: appdir + '/'
@@ -318,8 +323,9 @@ module.exports = {
318323
bddStdin('\n', 'y\n', 'n\n');
319324
process.argv = ['node', appdir + '/artisan', 'laravel:config'];
320325
var unhookIntercept = intercept(function onIntercept(txt) {
321-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
322-
// return '';
326+
if (typeof txt === 'string') {
327+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
328+
}
323329
});
324330
app.init({
325331
chdir: appdir + '/'

test/Commands/testMakeCommand.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ module.exports = {
2828
bddStdin('');
2929
process.argv = ['node', appdir + '/artisan', 'make:command command'];
3030
var unhookIntercept = intercept(function onIntercept(txt) {
31-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
31+
if (typeof txt === 'string') {
32+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
33+
}
3234
});
3335
app.init({
3436
chdir: appdir + '/'
@@ -57,7 +59,9 @@ module.exports = {
5759
fs: fsMock
5860
});
5961
var unhookIntercept = intercept(function onIntercept(txt) {
60-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
62+
if (typeof txt === 'string') {
63+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
64+
}
6165
});
6266
app.init({
6367
chdir: appdir + '/'

test/Commands/testMissingJob.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ module.exports = {
3131
process.argv = ['node', appdir + '/artisan', 'make:job'];
3232
bddStdin('');
3333
var unhookIntercept = intercept(function onIntercept(txt) {
34-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
35-
// return '';
34+
if (typeof txt === 'string') {
35+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
36+
}
3637
});
3738
app.init({
3839
chdir: appdir + '/'

test/Commands/testModelsCreator.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ module.exports = {
3737
bddStdin('');
3838
process.argv = ['node', appdir + '/artisan', 'make:models'];
3939
var unhookIntercept = intercept(function onIntercept(txt) {
40-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
41-
// return '';
40+
if (typeof txt === 'string') {
41+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
42+
}
4243
});
4344
app.init({
4445
chdir: appdir + '/'
@@ -68,8 +69,9 @@ module.exports = {
6869
bddStdin('');
6970
process.argv = ['node', appdir + '/artisan', 'make:models'];
7071
var unhookIntercept = intercept(function onIntercept(txt) {
71-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
72-
// return '';
72+
if (typeof txt === 'string') {
73+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
74+
}
7375
});
7476
app.init({
7577
chdir: appdir + '/'
@@ -100,8 +102,9 @@ module.exports = {
100102
bddStdin('');
101103
process.argv = ['node', appdir + '/artisan', 'make:models'];
102104
var unhookIntercept = intercept(function onIntercept(txt) {
103-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
104-
// return '';
105+
if (typeof txt === 'string') {
106+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
107+
}
105108
});
106109
app.init({
107110
chdir: appdir + '/'
@@ -142,8 +145,9 @@ module.exports = {
142145

143146
process.argv = ['node', appdir + '/artisan', 'make:models'];
144147
var unhookIntercept = intercept(function onIntercept(txt) {
145-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
146-
// return '';
148+
if (typeof txt === 'string') {
149+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
150+
}
147151
});
148152
app.init({
149153
chdir: appdir + '/'

test/bootstrap/testInitCommand.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ module.exports = {
2424
process.argv = ['node', appdir + '/artisan', 'help'];
2525
bddStdin('');
2626
var unhookIntercept = intercept(function onIntercept(txt) {
27-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
27+
if (typeof txt === 'string') {
28+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
29+
}
2830
// return '';
2931
});
3032
process.stdin.destroy = function stdinDestroy() {
@@ -46,8 +48,9 @@ module.exports = {
4648
process.argv = ['node', appdir + '/artisan', 'command:notfound'];
4749
bddStdin('');
4850
var unhookIntercept = intercept(function onIntercept(txt) {
49-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
50-
// return '';
51+
if (typeof txt === 'string') {
52+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
53+
}
5154
});
5255
rewire('../utils/bootstrap');
5356
app.init({

test/bootstrap/testInitIndex.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ module.exports = {
2121
test.expect(4);
2222
var stdout = [];
2323
var unhookIntercept = intercept(function onIntercept(txt) {
24-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
25-
// return '';
24+
if (typeof txt === 'string') {
25+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
26+
}
2627
});
2728
var appTest = rewire('../../bootstrap/app');
2829
var fakeRedis = new FakeRedis();

test/lib/shell/plugins/testHelp.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ module.exports = {
2121
'test help plugin default settings': function test1(test) {
2222
var stdout = [];
2323
var unhookIntercept = intercept(function onIntercept(txt) {
24-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
25-
// return '';
24+
if (typeof txt === 'string') {
25+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
26+
}
2627
});
2728
process.argv = ['node', appdir + '/artisan'];
2829
bddStdin('help\n', 'quit\n');
@@ -48,8 +49,9 @@ module.exports = {
4849
var stdout = [];
4950
process.argv = ['node', appdir + '/artisan'];
5051
var unhookIntercept = intercept(function onIntercept(txt) {
51-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
52-
// return '';
52+
if (typeof txt === 'string') {
53+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
54+
}
5355
});
5456
bddStdin('help\n', 'quit\n');
5557
app.init({
@@ -75,8 +77,9 @@ module.exports = {
7577
'test help plugin help command': function customIntroduction(test) {
7678
var stdout = [];
7779
var unhookIntercept = intercept(function onIntercept(txt) {
78-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
79-
// return '';
80+
if (typeof txt === 'string') {
81+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
82+
}
8083
});
8184
process.argv = ['node', appdir + '/artisan'];
8285
bddStdin('help test\n', 'help test:second\n', 'help test:third\n', 'help not:found\n', 'quit\n');

test/lib/shell/plugins/testHistory.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ module.exports = {
2121
process.argv = ['node', appdir + '/artisan'];
2222
bddStdin('help\n', BddStdin.keys.up, '\n', 'quit\n');
2323
var unhookIntercept = intercept(function onIntercept(txt) {
24-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
25-
// return '';
24+
if (typeof txt === 'string') {
25+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
26+
}
2627
});
2728
app.init({
2829
chdir: appdir + '/'

test/lib/shell/plugins/testRouter.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ module.exports = {
2424
'quit\n'
2525
);
2626
var unhookIntercept = intercept(function onIntercept(txt) {
27-
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
28-
// return '';
27+
if (typeof txt === 'string') {
28+
stdout.push(txt.replace(/\u001b\[.*?m/g, ''));
29+
}
2930
});
3031
app.init({
3132
chdir: appdir + '/'

0 commit comments

Comments
 (0)