From 3215249d53350edea2a8d3d84171eb5027f9cf64 Mon Sep 17 00:00:00 2001 From: hasundue Date: Fri, 1 Mar 2024 10:37:31 +0900 Subject: [PATCH] fix: unexpected subpaths in import maps by updates --- lib/file.ts | 7 +------ test/snapshots/file_test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/file.ts b/lib/file.ts index 868ad703..bf509f61 100644 --- a/lib/file.ts +++ b/lib/file.ts @@ -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"; @@ -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)); } diff --git a/test/snapshots/file_test.ts.snap b/test/snapshots/file_test.ts.snap index 23304e71..ff5a1738 100644 --- a/test/snapshots/file_test.ts.snap +++ b/test/snapshots/file_test.ts.snap @@ -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", "/": "./"