Skip to content

Commit 55e6002

Browse files
committed
fix set-react-version not handling missing template
1 parent 4080b6e commit 55e6002

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

packages/app/scripts/internal/set-react-version.mts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,23 @@ function fetchPackageInfo(pkg: string, version: string): Promise<Manifest> {
8585
/**
8686
* Fetches the template manifest for the specified React Native version.
8787
*/
88-
function fetchTemplateManifest(version: string): Promise<Manifest> {
88+
async function fetchTemplateManifest(version: string): Promise<Manifest> {
8989
const url = `https://raw.githubusercontent.com/react-native-community/template/refs/heads/${version}-stable/template/package.json`;
9090
console.log(`Fetching template manifest from ${url}`);
91-
return fetch(url, {
91+
const res = await fetch(url, {
9292
headers: {
9393
Accept:
9494
"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*",
9595
},
96-
})
97-
.then((res) => res.text())
98-
.then((text) => JSON.parse(text));
96+
});
97+
98+
const body = await res.text();
99+
if (res.status !== 200) {
100+
console.error(`Failed to fetch template: ${body}`);
101+
return { name: "", version: "" };
102+
}
103+
104+
return JSON.parse(body);
99105
}
100106

101107
/**

0 commit comments

Comments
 (0)