• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4const assert = require('assert');
5const path = require('path');
6
7const { createRequireFromPath } = require('module');
8
9const fixPath = path.resolve(__dirname, '..', 'fixtures');
10const p = path.join(fixPath, path.sep);
11
12const req = createRequireFromPath(p);
13const reqFromNotDir = createRequireFromPath(fixPath);
14
15assert.strictEqual(req('./baz'), 'perhaps I work');
16assert.throws(() => {
17  reqFromNotDir('./baz');
18}, { code: 'MODULE_NOT_FOUND' });
19