Skip to content

Commit 0f8a323

Browse files
furnoxMylesBorins
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 fc67a95 commit 0f8a323

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed
+19-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var path = require('path');
5-
var child_process = require('child_process');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const path = require('path');
5+
const child_process = require('child_process');
66

7-
var testScript = path.join(common.fixturesDir, 'catch-stdout-error.js');
7+
const testScript = path.join(common.fixturesDir, 'catch-stdout-error.js');
88

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

14-
var child = child_process.exec(cmd);
15-
var output = '';
16-
var outputExpect = { 'code': 'EPIPE',
17-
'errno': 'EPIPE',
18-
'syscall': 'write' };
14+
const child = child_process.exec(cmd);
15+
let output = '';
16+
const outputExpect = {
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.deepEqual(output, outputExpect);
3336
console.log('ok');
34-
});
37+
}));

0 commit comments

Comments
 (0)