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