Skip to content

Commit

Permalink
fix: unexpected subpaths in import maps by updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Mar 1, 2024
1 parent 2d4a93f commit 3215249
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions lib/file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assertExists } from "./std/assert.ts";
import { parse as parseJsonc } from "./std/jsonc.ts";
import { detectEOL } from "./std/fs.ts";
import { toUrl } from "./dependency.ts";
Expand Down Expand Up @@ -127,11 +126,7 @@ async function writeToImportMap(
const content = await Deno.readTextFile(update.path);
const json = parseJsonc(content) as unknown as ImportMapJson;
for (const dependency of update.dependencies) {
assertExists(dependency.map);
json.imports[dependency.map.key!] = dependency.map.resolved.replace(
toUrl(dependency.from),
toUrl(dependency.to),
);
json.imports[dependency.map!.key!] = toUrl(dependency.to);
}
await Deno.writeTextFile(update.path, JSON.stringify(json, null, 2));
}
2 changes: 1 addition & 1 deletion test/snapshots/file_test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ snapshot[`write - import_map/mod.ts 1`] = `
[
'{
"imports": {
"std/": "https://deno.land/std@123.456.789/assert.ts",
"std/": "https://deno.land/std@123.456.789/",
"deno_graph": "https://deno.land/x/deno_graph@123.456.789/mod.ts",
"node-emoji": "npm:node-emoji@123.456.789",
"/": "./"
Expand Down

0 comments on commit 3215249

Please sign in to comment.