Improve source map script

This commit is contained in:
Koen Vlaswinkel
2024-10-22 12:06:28 +02:00
parent 4ed616769c
commit 426db0f758

View File

@@ -41,6 +41,7 @@ async function extractSourceMap() {
const releaseAssetsDirectory = resolve( const releaseAssetsDirectory = resolve(
__dirname, __dirname,
"..", "..",
"artifacts",
"release-assets", "release-assets",
versionNumber, versionNumber,
); );
@@ -64,7 +65,9 @@ async function extractSourceMap() {
]); ]);
const sourcemapAsset = release.assets.find( const sourcemapAsset = release.assets.find(
(asset) => asset.name === `vscode-codeql-sourcemaps-${versionNumber}.zip`, (asset) =>
asset.label === `vscode-codeql-sourcemaps-${versionNumber}.zip` ||
asset.name === "vscode-codeql-sourcemaps.zip",
); );
if (sourcemapAsset) { if (sourcemapAsset) {
@@ -213,9 +216,7 @@ extractSourceMap().catch((e: unknown) => {
function runGh(args: readonly string[]): string { function runGh(args: readonly string[]): string {
const gh = spawnSync("gh", args); const gh = spawnSync("gh", args);
if (gh.status !== 0) { if (gh.status !== 0) {
throw new Error( throw new Error(`Failed to run gh ${args.join(" ")}: ${gh.stderr}`);
`Failed to get the source map for ${versionNumber}: ${gh.stderr}`,
);
} }
return gh.stdout.toString("utf-8"); return gh.stdout.toString("utf-8");
} }
@@ -227,6 +228,7 @@ function runGhJSON<T>(args: readonly string[]): T {
type ReleaseAsset = { type ReleaseAsset = {
id: string; id: string;
name: string; name: string;
label: string;
}; };
type Release = { type Release = {