1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-27 16:10:57 -05:00
denoland-deno/cli/tests/testdata/npm/registry/@denotest/create-require/1.0.0/index.js
Yoshiya Hinosawa e4fe5ee72a
fix(ext/node): allow absolute path in createRequire (#16853)
Co-authored-by: David Sherret <dsherret@gmail.com>
2022-11-29 14:13:14 +09: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);
}