mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(ext/node): allow absolute path in createRequire (#16853)
Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
parent
d3299c2d6c
commit
e4fe5ee72a
5 changed files with 37 additions and 3 deletions
|
@ -1,6 +1,12 @@
|
|||
[WILDCARD]
|
||||
function
|
||||
function
|
||||
function
|
||||
function
|
||||
function
|
||||
function
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received https://example.com/
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received https://example.com/
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 1
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received foo
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received ./foo
|
||||
|
|
|
@ -2,6 +2,10 @@ import { createRequire } from "module";
|
|||
|
||||
console.log(typeof createRequire(import.meta.url));
|
||||
console.log(typeof createRequire(new URL(import.meta.url)));
|
||||
console.log(typeof createRequire("/"));
|
||||
console.log(typeof createRequire("/foo"));
|
||||
console.log(typeof createRequire("/foo/"));
|
||||
console.log(typeof createRequire("c:\\foo"));
|
||||
try {
|
||||
createRequire("https://example.com/");
|
||||
} catch (e) {
|
||||
|
@ -17,3 +21,13 @@ try {
|
|||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
try {
|
||||
createRequire("foo");
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
try {
|
||||
createRequire("./foo");
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue