Skip to content

Commit

Permalink
build: Improve update-sapui5-types script
Browse files Browse the repository at this point in the history
- Better handling of a missing version.

- Ensures that errors are logged to the console. `tsx` doesn't seem to
properly handle `process.stderr.write`, but `console.log` works fine.
  • Loading branch information
matz3 committed Jan 7, 2025
1 parent 87c21e6 commit 111ce1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion scripts/metadataProvider/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const RAW_API_JSON_FILES_FOLDER = fileURLToPath(new URL(`../../tmp/apiJson`, imp
export async function fetchAndExtractApiJsons(url: string) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Unexpected response ${response.statusText}`);
if (response.status === 404) {
throw new Error(`The requested version does not exist`);
} else {
throw new Error(`Unexpected response ${response.status}: ${response.statusText}`);
}
}

if (response.body && response.body instanceof ReadableStream) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/update-sapui5-types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import createMetadataInfo from "./metadataProvider/createMetadataInfo.js";
import createPseudoModulesInfo from "./metadataProvider/createPseudoModulesInfo.js";
import {cleanup, fetchAndExtractApiJsons} from "./metadataProvider/helpers.js";
Expand Down Expand Up @@ -28,6 +29,6 @@ try {
// Update @sapui5/types npm package
await execFile("npm", ["install", "-E", `@sapui5/types@${version}`]);
} catch (err) {
process.stderr.write(String(err));
console.log(err);
process.exit(1);
}

0 comments on commit 111ce1f

Please sign in to comment.