Skip to content

Commit 0787861

Browse files
committed
update
1 parent 9e6989c commit 0787861

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/stats.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
uses: actions/github-script@v6
1717
with:
1818
script: |
19+
const fetch = require('node-fetch');
20+
1921
async function fetchAndCountData(url) {
2022
const counts = {
2123
templates: 0,
@@ -30,13 +32,13 @@ jobs:
3032
do {
3133
try {
3234
// Construct the URL with cursor if available
33-
const fetchUrl = cursor ? ${url}?cursor=${encodeURIComponent(cursor)} : url;
35+
const fetchUrl = cursor ? `${url}?cursor=${encodeURIComponent(cursor)}` : url;
3436
3537
// Fetch the data from the API
3638
const response = await fetch(fetchUrl);
3739
3840
if (!response.ok) {
39-
throw new Error(HTTP error! status: ${response.status});
41+
throw new Error(`HTTP error! status: ${response.status}`);
4042
}
4143
4244
const responseData = await response.json();
@@ -64,7 +66,7 @@ jobs:
6466
// Update the cursor for the next page
6567
cursor = responseData.nextCursor || null;
6668
} catch (error) {
67-
core.setFailed(Error fetching data: ${error.message});
69+
console.error(`Error fetching data: ${error.message}`);
6870
cursor = null; // Exit the loop on error
6971
}
7072
} while (cursor);
@@ -82,4 +84,4 @@ jobs:
8284
const url = "https://pkg.pr.new/stats";
8385
const counts = await fetchAndCountData(url);
8486
85-
console.log("Counts:", counts);
87+
console.log("Counts:", counts);

0 commit comments

Comments
 (0)