Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
fix: typescript-deno-plugin may not find modules and cause `typescr…
Browse files Browse the repository at this point in the history
…ipt` to crash
  • Loading branch information
axetroy committed Feb 5, 2020
1 parent 6f35673 commit 8bdc5db
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions typescript-deno-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ function convertRemoteToLocalCache(moduleName: string): string {

if (!existsSync(filepath)) {
const headersPath = `${filepath}.headers.json`;
const headers: IDenoModuleHeaders = JSON.parse(
fs.readFileSync(headersPath, { encoding: "utf-8" })
);
if (moduleName !== headers.redirect_to) {
const redirectFilepath = convertRemoteToLocalCache(headers.redirect_to);
logger.info(`redirect "${filepath}" to "${redirectFilepath}".`);
filepath = redirectFilepath;
if (existsSync(headersPath)) {
const headers: IDenoModuleHeaders = JSON.parse(
fs.readFileSync(headersPath, { encoding: "utf-8" })
);
if (moduleName !== headers.redirect_to) {
const redirectFilepath = convertRemoteToLocalCache(headers.redirect_to);
logger.info(`redirect "${filepath}" to "${redirectFilepath}".`);
filepath = redirectFilepath;
}
}
}

Expand Down

0 comments on commit 8bdc5db

Please sign in to comment.