summaryrefslogtreecommitdiff
path: root/test/parallel/test-stdin-script-child.js
diff options
context:
space:
mode:
authorEbrahim Byagowi <ebrahim@gnu.org>2017-05-13 12:28:18 +0430
committerAnna Henningsen <anna@addaleax.net>2017-05-23 20:41:13 +0200
commit594b5d7b8970a68d9cd66f629cf1862cfca68412 (patch)
treed0e48763b3669226db99d2c902074dde21d10648 /test/parallel/test-stdin-script-child.js
parent7a1dc1fba30eb6e883235d98aac144b39b97cf1b (diff)
downloadandroid-node-v8-594b5d7b8970a68d9cd66f629cf1862cfca68412.tar.gz
android-node-v8-594b5d7b8970a68d9cd66f629cf1862cfca68412.tar.bz2
android-node-v8-594b5d7b8970a68d9cd66f629cf1862cfca68412.zip
cmd: support dash as stdin alias
PR-URL: https://github.com/nodejs/node/pull/13012 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test/parallel/test-stdin-script-child.js')
-rw-r--r--test/parallel/test-stdin-script-child.js49
1 files changed, 25 insertions, 24 deletions
diff --git a/test/parallel/test-stdin-script-child.js b/test/parallel/test-stdin-script-child.js
index 81eb3ea5b4..d3d22a9a82 100644
--- a/test/parallel/test-stdin-script-child.js
+++ b/test/parallel/test-stdin-script-child.js
@@ -2,31 +2,32 @@
const common = require('../common');
const assert = require('assert');
-const spawn = require('child_process').spawn;
-const child = spawn(process.execPath, [], {
- env: Object.assign(process.env, {
- NODE_DEBUG: process.argv[2]
- })
-});
-const wanted = `${child.pid}\n`;
-let found = '';
+const { spawn } = require('child_process');
+for (const args of [[], ['-']]) {
+ const child = spawn(process.execPath, args, {
+ env: Object.assign(process.env, {
+ NODE_DEBUG: process.argv[2]
+ })
+ });
+ const wanted = `${child.pid}\n`;
+ let found = '';
-child.stdout.setEncoding('utf8');
-child.stdout.on('data', function(c) {
- found += c;
-});
+ child.stdout.setEncoding('utf8');
+ child.stdout.on('data', function(c) {
+ found += c;
+ });
-child.stderr.setEncoding('utf8');
-child.stderr.on('data', function(c) {
- console.error(`> ${c.trim().split(/\n/).join('\n> ')}`);
-});
+ child.stderr.setEncoding('utf8');
+ child.stderr.on('data', function(c) {
+ console.error(`> ${c.trim().split(/\n/).join('\n> ')}`);
+ });
-child.on('close', common.mustCall(function(c) {
- assert.strictEqual(c, 0);
- assert.strictEqual(found, wanted);
- console.log('ok');
-}));
+ child.on('close', common.mustCall(function(c) {
+ assert.strictEqual(c, 0);
+ assert.strictEqual(found, wanted);
+ }));
-setTimeout(function() {
- child.stdin.end('console.log(process.pid)');
-}, 1);
+ setTimeout(function() {
+ child.stdin.end('console.log(process.pid)');
+ }, 1);
+}