mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

Fixes: https://github.com/nodejs/node/issues/23710 PR-URL: https://github.com/nodejs/node/pull/23818 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
19 lines
483 B
JavaScript
19 lines
483 B
JavaScript
'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' });
|