Skip to content

Commit

Permalink
fix: filter 7z in mingw asset list
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Sep 4, 2024
1 parent 3e4a96d commit 6e3b572
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/legacy/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/gcc/assets-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { saveGitHubAssetList } from "../utils/github/fetch-assets.ts"
*/
async function main() {
// https://github.com/brechtsanders/winlibs_mingw/releases
await saveGitHubAssetList("brechtsanders", "winlibs_mingw", "./src/gcc/github_brechtsanders_winlibs_mingw.json")
await saveGitHubAssetList(
"brechtsanders",
"winlibs_mingw",
"./src/gcc/github_brechtsanders_winlibs_mingw.json",
(asset) => asset.endsWith(".7z"),
)
}

main().catch((err) => {
Expand Down
1 change: 0 additions & 1 deletion src/gcc/gcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async function getGccPackageInfo(version: string, platform: NodeJS.Platform, arc
: arch === "ia32"
? "i386"
: arch,
filterName: (name) => name.endsWith(".7z"),
},
)

Expand Down
2 changes: 1 addition & 1 deletion src/gcc/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/utils/github/fetch-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import type { Assets } from "./load-assets.ts"
* @param prerelease Whether to include prereleases
*/

async function fetchGitHubAssetList(owner: string, repo: string, prerelease = false) {
async function fetchGitHubAssetList(
owner: string,
repo: string,
filterAssets?: (asset: string) => boolean,
prerelease = false,
) {
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
})
Expand Down Expand Up @@ -47,7 +52,11 @@ async function fetchGitHubAssetList(owner: string, repo: string, prerelease = fa
}

const assets_ref = assets[release.tag_name]

for (const asset of release.assets) {
if (filterAssets !== undefined && !filterAssets(asset.name)) {
continue
}
assets_ref.push(asset.name)
}
}
Expand All @@ -67,8 +76,9 @@ export async function saveGitHubAssetList(
owner: string,
repo: string,
path: string,
filterAssets?: (asset: string) => boolean,
) {
const assets = await fetchGitHubAssetList(owner, repo)
const assets = await fetchGitHubAssetList(owner, repo, filterAssets, false)

const jsonStringify = JsonStringify.configure({
deterministic: compareVersion,
Expand Down

0 comments on commit 6e3b572

Please sign in to comment.