-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvert_maps.ts
More file actions
41 lines (33 loc) · 1.12 KB
/
convert_maps.ts
File metadata and controls
41 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2025 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Small utility that converts the scopes encoding of the
* source maps in the "maps/" directory from a given version to the currently
* checked out version.
*
* The given version must be a released version on JSR.
*/
import { expandGlob } from "@std/fs";
import { parseArgs } from "@std/cli/parse-args";
import { encode } from "../src/mod.ts";
if (import.meta.main) {
const flags = parseArgs(Deno.args, {
string: ["from"],
});
if (!flags.from) {
throw new Error("--from is mandatory");
}
const oldCodec = await import(
`jsr:@chrome-devtools/source-map-scopes-codec@${flags.from}`
);
for await (
const file of expandGlob("maps/*.js.map", { root: import.meta.dirname })
) {
const mapContent = Deno.readTextFileSync(file.path);
const mapJson = JSON.parse(mapContent);
const info = oldCodec.decode(mapJson);
encode(info, mapJson);
Deno.writeTextFileSync(file.path, JSON.stringify(mapJson));
}
}