• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const assert = require('assert');
4const cp = require('child_process');
5
6// This test spawns itself with an argument to indicate when it is a child to
7// easily and portably print the value of argv[0]
8if (process.argv[2] === 'child') {
9  console.log(process.argv0);
10  return;
11}
12
13const noArgv0 = cp.spawnSync(process.execPath, [__filename, 'child']);
14assert.strictEqual(noArgv0.stdout.toString().trim(), process.execPath);
15
16const withArgv0 = cp.spawnSync(process.execPath, [__filename, 'child'],
17                               { argv0: 'withArgv0' });
18assert.strictEqual(withArgv0.stdout.toString().trim(), 'withArgv0');
19