mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: use fixtures.fileURL when appropriate
PR-URL: https://github.com/nodejs/node/pull/48990 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
1353681edf
commit
a061781da3
2 files changed
+3
-14
No files matched your search
@@ -3,19 +3,9 @@
|
||||
const common = require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
function pathToFileURL(p) {
|
||||
if (!path.isAbsolute(p))
|
||||
throw new Error('Path must be absolute');
|
||||
if (common.isWindows && p.startsWith('\\\\'))
|
||||
p = p.slice(2);
|
||||
return new URL(`file://${p}`);
|
||||
}
|
||||
|
||||
const p = path.resolve(fixtures.fixturesDir, 'a.js');
|
||||
const url = pathToFileURL(p);
|
||||
const url = fixtures.fileURL('a.js');
|
||||
|
||||
assert(url instanceof URL);
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const fixtures = require('../common/fixtures');
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
const { createRequire } = require('module');
|
||||
|
||||
const p = path.resolve(__dirname, '..', 'fixtures', 'fake.js');
|
||||
const u = new URL(`file://${p}`);
|
||||
const u = fixtures.fileURL('fake.js');
|
||||
|
||||
const reqToo = createRequire(u);
|
||||
assert.deepStrictEqual(reqToo('./experimental'), { ofLife: 42 });
|
||||
|
||||
Reference in new issue
Block a user