33 lines
972 B
TypeScript
33 lines
972 B
TypeScript
|
import { resolve, toFileUrl } from "https://deno.land/std/path/mod.ts";
|
||
|
|
||
|
async function main()
|
||
|
{
|
||
|
// Look for the deno.json file in the current directory
|
||
|
const denoJsonPath = resolve("./deno.json");
|
||
|
|
||
|
// Read and parse the deno.json file
|
||
|
const denoJson = JSON.parse(await Deno.readTextFile("./deno.json"));
|
||
|
|
||
|
// Check if compilerOptions and types are defined
|
||
|
if (denoJson.compilerOptions?.types) {
|
||
|
const types:string[] = denoJson.compilerOptions.types;
|
||
|
|
||
|
// Iterate over each type file and cache it
|
||
|
for (const typeFile of types) {
|
||
|
let lookup:string = typeFile;
|
||
|
if(!typeFile.startsWith("http"))
|
||
|
{
|
||
|
lookup = toFileUrl(resolve(Deno.cwd(), typeFile)).href;
|
||
|
}
|
||
|
console.log(`Caching ${lookup}`);
|
||
|
await import(lookup); // This will cache the file
|
||
|
}
|
||
|
} else {
|
||
|
console.log("No types found in compilerOptions.");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
main().catch((error) => {
|
||
|
console.error("Error:", error);
|
||
|
Deno.exit(1);
|
||
|
});
|