33 lines
959 B
TypeScript
33 lines
959 B
TypeScript
import { resolve, toFileUrl } from "https://deno.land/std/path/mod.ts";
|
|
|
|
async function main()
|
|
{
|
|
// 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(`Scan found types: ${lookup}`);
|
|
await import(lookup); // This will cache the file
|
|
}
|
|
|
|
console.log("Scan complete; be sure to restart the Deno Language Server!!");
|
|
|
|
} else {
|
|
console.log("No types found in compilerOptions.");
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("Error:", error);
|
|
Deno.exit(1);
|
|
}); |