1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-20 22:34:46 -05:00
denoland-deno/tests/registry/npm/@denotest/create-require/1.0.0/index.js
David Sherret 1587387bcc
chore(test): move npm registries to separate servers and to the tests/registry folder (#23717)
1. Moves the npm registries to their own dedicated ports.
2. Moves the data files out of `tests/testdata/npm/registry` to
`tests/registry/npm`.
2024-05-07 01:06:01 +00:00

33 lines
728 B
JavaScript

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) {
console.log(e.message);
}
try {
createRequire(new URL("https://example.com/"));
} catch (e) {
console.log(e.message);
}
try {
createRequire(1);
} catch (e) {
console.log(e.message);
}
try {
createRequire("foo");
} catch (e) {
console.log(e.message);
}
try {
createRequire("./foo");
} catch (e) {
console.log(e.message);
}