• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3if (process.config.variables.node_without_node_options)
4  common.skip('missing NODE_OPTIONS support');
5
6// Test options specified by env variable.
7
8const assert = require('assert');
9const exec = require('child_process').execFile;
10
11const tmpdir = require('../common/tmpdir');
12tmpdir.refresh();
13
14disallow('--version');
15disallow('-v');
16disallow('--help');
17disallow('-h');
18disallow('--eval');
19disallow('-e');
20disallow('--print');
21disallow('-p');
22disallow('-pe');
23disallow('--check');
24disallow('-c');
25disallow('--interactive');
26disallow('-i');
27disallow('--v8-options');
28disallow('--expose_internals');
29disallow('--expose-internals');
30disallow('--');
31disallow('--test');
32
33function disallow(opt) {
34  const env = { ...process.env, NODE_OPTIONS: opt };
35  exec(process.execPath, { cwd: tmpdir.path, env }, common.mustCall((err) => {
36    const message = err.message.split(/\r?\n/)[1];
37    const expect = `${process.execPath}: ${opt} is not allowed in NODE_OPTIONS`;
38
39    assert.strictEqual(err.code, 9);
40    assert.strictEqual(message, expect);
41  }));
42}
43