Skip to content

Commit

Permalink
Replace request with fetch in ci-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ljowen committed Mar 11, 2025
1 parent 50544f3 commit 605a8a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
39 changes: 13 additions & 26 deletions buildprocess/ci-cleanup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
const childProcess = require("child_process");
const fs = require("fs");
const request = require("request");

function requestPromise(options) {
return new Promise((resolve, reject) => {
request(options, (error, response, body) => {
if (error) {
reject(error);
} else {
resolve(response);
}
});
});
}

function getAllBranches(repo) {
const baseUrl = "https://api.github.com/repos/" + repo + "/branches";
Expand All @@ -24,24 +11,24 @@ function getAllBranches(repo) {
++page;

let url = baseUrl + "?page=" + page;
return requestPromise({
url: url,
return fetch(url, {
headers: {
"User-Agent": "TerriaJS CI",
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`
}
}).then((pageResponse) => {
const pageOfBranches = JSON.parse(pageResponse.body);
result.push(
...pageOfBranches.filter(
(branch) => branch.name.indexOf("greenkeeper/") !== 0
)
);
})
.then((response) => response.json())
.then((pageOfBranches) => {
result.push(
...pageOfBranches.filter(
(branch) => branch.name.indexOf("greenkeeper/") !== 0
)
);

if (pageOfBranches.length > 0) {
return getNextPage();
}
});
if (pageOfBranches.length > 0) {
return getNextPage();
}
});
}

return getNextPage().then(() => result);
Expand Down
1 change: 0 additions & 1 deletion buildprocess/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gh api /repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} -f state=pending -f co
# Install some tools we need from npm
npm install -g https://github.com/terriajs/sync-dependencies
npm install -g yarn@^1.19.0
yarn add -W [email protected]

# Clone and build TerriaMap, using this version of TerriaJS
TERRIAJS_COMMIT_HASH=$(git rev-parse HEAD)
Expand Down

0 comments on commit 605a8a8

Please sign in to comment.