Skip to content

Commit

Permalink
Revert "Revert "fix: use is-url-online to validate the download links""
Browse files Browse the repository at this point in the history
This reverts commit edc37d2.
  • Loading branch information
aminya committed Aug 8, 2022
1 parent edc37d2 commit edbca63
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.mjs.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"exec-powershell": "workspace:*",
"execa": "^5.1.1",
"extension-tools": "workspace:*",
"is-url-online": "^1.4.0",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/llvm/__tests__/llvm.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isValidUrl } from "../../utils/http/validate_url"
import { isUrlOnline } from "is-url-online"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect"
import execa from "execa"
Expand All @@ -14,7 +14,7 @@ jest.setTimeout(400000)
async function testUrl(version: string) {
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, process.platform, version, getUrl)

if (!(await isValidUrl(url))) {
if (!(await isUrlOnline(url))) {
throw new Error(`Failed to install Version: ${version} => ${specificVersion} \n URL: ${url}`)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/llvm/llvm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from "path"
import semverLte from "semver/functions/lte"
import semverMajor from "semver/functions/major"
import { isValidUrl } from "../utils/http/validate_url"
import { isUrlOnline } from "is-url-online"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { extractExe, extractTarByExe } from "../utils/setup/extract"
import {
Expand Down Expand Up @@ -231,7 +231,7 @@ async function getWin32Url(version: string): Promise<string | null> {
let fallback = false
if (olderThan9_1) {
url = getReleaseUrl(version, prefix, suffix)
if (!(await isValidUrl(url))) {
if (!(await isUrlOnline(url))) {
fallback = true // fallback to github
}
}
Expand Down
13 changes: 0 additions & 13 deletions src/utils/http/validate_url.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/utils/setup/version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isValidUrl } from "../http/validate_url"
import { isUrlOnline } from "is-url-online"
import semverCompare from "semver/functions/compare"
import semverCoerce from "semver/functions/coerce"
import semverValid from "semver/functions/valid"
Expand Down Expand Up @@ -42,7 +42,7 @@ export async function getSpecificVersionAndUrl(
if (platform === "linux" && version.includes("ubuntu")) {
const url = await getUrl(platform, version)
// eslint-disable-next-line no-await-in-loop
if (url !== null && (await isValidUrl(url))) {
if (url !== null && (await isUrlOnline(url))) {
return [version, url]
}
}
Expand All @@ -55,7 +55,7 @@ export async function getSpecificVersionAndUrl(
// eslint-disable-next-line no-await-in-loop
const url = await getUrl(platform, specificVersion)
// eslint-disable-next-line no-await-in-loop
if (url !== null && (await isValidUrl(url))) {
if (url !== null && (await isUrlOnline(url))) {
return [specificVersion, url]
}
}
Expand Down

0 comments on commit edbca63

Please sign in to comment.