1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
'use strict';
const child_process = require('child_process');
const tap = require('tap');
const semver = require('semver');
tap.beforeEach(() => {
delete process.env.DISABLE_V8_COMPILE_CACHE;
});
tap.test('require.resolve.paths module', t => {
const psWithoutCache = child_process.spawnSync(
process.execPath,
[require.resolve('./fixtures/require-resolve-paths'), 'tap'],
{cwd: __dirname}
);
const psWithCache = child_process.spawnSync(
process.execPath,
[
'--require',
'..',
require.resolve('./fixtures/require-resolve-paths'),
'tap',
],
{cwd: __dirname}
);
const actual = JSON.parse(psWithCache.stdout);
const expected = JSON.parse(psWithoutCache.stdout);
t.same(actual, expected);
t.equal(psWithCache.stderr.toString(), '');
t.equal(psWithCache.status, 0);
t.equal(
actual.hasRequireResolve,
semver.satisfies(process.versions.node, '>=8.9.0')
);
t.end();
});
tap.test('require.resolve.paths relative', t => {
const psWithoutCache = child_process.spawnSync(
process.execPath,
[require.resolve('./fixtures/require-resolve-paths'), './foo'],
{cwd: __dirname}
);
const psWithCache = child_process.spawnSync(
process.execPath,
[
'--require',
'..',
require.resolve('./fixtures/require-resolve-paths'),
'./foo',
],
{cwd: __dirname}
);
t.same(JSON.parse(psWithCache.stdout), JSON.parse(psWithoutCache.stdout));
t.equal(psWithCache.stderr.toString(), '');
t.equal(psWithCache.status, 0);
t.end();
});
|