Skip to content

Commit

Permalink
feat: add get-works package to validate the URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 8, 2022
1 parent 91ab4d1 commit 4d3cf92
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 152 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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"exec-powershell": "workspace:*",
"execa": "^5.1.1",
"extension-tools": "workspace:*",
"is-link-working": "github:aminya/node-is-link-working#4a10987",
"get-works": "workspace:*",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
Expand Down
26 changes: 26 additions & 0 deletions packages/ok-status/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "get-works",
"version": "1.0.0",
"description": "Check if the GET request for the given URL works",
"homepage": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"root-tools": "workspace:*"
},
"keywords": [
"url",
"link",
"uri",
"working",
"check",
"alive",
"ok",
"broken"
]
}
19 changes: 19 additions & 0 deletions packages/ok-status/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as https from "https"

/**
* Check if the GET request for the given URL works
*
* @param url The given URL
* @returns A promise that resolves to a boolean indicating if the URL works
*/
export function getWorks(url: string): Promise<boolean> {
return new Promise<boolean>((resolve) => {
https.get(url, (res) => {
if (res.statusCode !== undefined && res.statusCode >= 200 && res.statusCode <= 399) {
resolve(true)
} else {
resolve(false)
}
})
})
}
7 changes: 7 additions & 0 deletions packages/ok-status/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./src"]
}
Loading

0 comments on commit 4d3cf92

Please sign in to comment.