summaryrefslogtreecommitdiff
path: root/test/parallel/test-module-main-preserve-symlinks-fail.js
blob: bbaf451c3ce539164fa43bc40a1a5fc2ba9ed7de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
require('../common');
const assert = require('assert');
const { execFileSync } = require('child_process');

const entryPoints = ['iDoNotExist', 'iDoNotExist.js', 'iDoNotExist.mjs'];
const flags = [[], ['--preserve-symlinks']];
const node = process.argv[0];

for (const args of flags) {
  for (const entryPoint of entryPoints) {
    try {
      execFileSync(node, args.concat(entryPoint));
    } catch (e) {
      assert(e.toString().match(/Error: Cannot find module/));
      continue;
    }
    assert.fail('Executing node with inexistent entry point should ' +
                `fail. Entry point: ${entryPoint}, Flags: [${args}]`);
  }
}