Skip to content

Commit ff3a1e6

Browse files
furnoxtargos
authored andcommitted
test: cleanup test-stdout-close-catch.js
Added common.mustCall in child process on 'close' callback Changed several 'var' statements to 'const' or 'let' where appropriate Also linting PR-URL: #10006 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]>
1 parent 49e7029 commit ff3a1e6

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed
Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varpath=require('path');
5-
varchild_process=require('child_process');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constpath=require('path');
5+
constchild_process=require('child_process');
66

7-
vartestScript=path.join(common.fixturesDir,'catch-stdout-error.js');
7+
consttestScript=path.join(common.fixturesDir,'catch-stdout-error.js');
88

9-
varcmd=JSON.stringify(process.execPath)+' '+
10-
JSON.stringify(testScript)+' | '+
11-
JSON.stringify(process.execPath)+' '+
12-
'-pe "process.stdin.on(\'data\' , () => process.exit(1))"';
9+
constcmd=JSON.stringify(process.execPath)+' '+
10+
JSON.stringify(testScript)+' | '+
11+
JSON.stringify(process.execPath)+' '+
12+
'-pe "process.stdin.on(\'data\' , () => process.exit(1))"';
1313

14-
varchild=child_process.exec(cmd);
15-
varoutput='';
16-
varoutputExpect={'code': 'EPIPE',
17-
'errno': 'EPIPE',
18-
'syscall': 'write'};
14+
constchild=child_process.exec(cmd);
15+
letoutput='';
16+
constoutputExpect={
17+
code: 'EPIPE',
18+
errno: 'EPIPE',
19+
syscall: 'write'
20+
};
1921

2022
child.stderr.on('data',function(c){
2123
output+=c;
2224
});
2325

24-
child.on('close',function(code){
26+
27+
child.on('close',common.mustCall(function(code){
2528
try{
2629
output=JSON.parse(output);
2730
}catch(er){
@@ -31,4 +34,4 @@ child.on('close', function(code){
3134

3235
assert.deepStrictEqual(output,outputExpect);
3336
console.log('ok');
34-
});
37+
}));

0 commit comments

Comments
(0)