mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
bf6ce47259
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>
19 lines
644 B
JavaScript
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'));
|