0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/known_issues/test-module-deleted-extensions.js
Rich Trott bf6ce47259 test: move tmpdir to submodule of common
Move tmpdir functionality to its own module (common/tmpdir).

PR-URL: https://github.com/nodejs/node/pull/17856
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-01-31 22:11:07 -08:00

19 lines
644 B
JavaScript

'use strict';
// Refs: https://github.com/nodejs/node/issues/4778
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const file = path.join(tmpdir.path, 'test-extensions.foo.bar');
tmpdir.refresh();
fs.writeFileSync(file, '', 'utf8');
require.extensions['.foo.bar'] = (module, path) => {};
delete require.extensions['.foo.bar'];
require.extensions['.bar'] = common.mustCall((module, path) => {
assert.strictEqual(module.id, file);
assert.strictEqual(path, file);
});
require(path.join(tmpdir.path, 'test-extensions'));