summaryrefslogtreecommitdiff
path: root/tools/util.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-11-02 15:37:10 -0600
committerGitHub <noreply@github.com>2023-11-02 15:37:10 -0600
commitec0e387d1c387d8708f1d252781e7d762c2ad508 (patch)
tree27966cd35c823a18a83ea866289506ebfe07dccd /tools/util.js
parent1d0856a4f1ef54ada163f1336100c45058e293d8 (diff)
chore: fix dlint version and sanity check version after download (#21058)
Follow-up to fix version error introduced in #21014
Diffstat (limited to 'tools/util.js')
-rw-r--r--tools/util.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/util.js b/tools/util.js
index a9962fc56..0d57213e0 100644
--- a/tools/util.js
+++ b/tools/util.js
@@ -16,7 +16,7 @@ export { delay } from "../test_util/std/async/delay.ts";
// [toolName] --version output
const versions = {
"dprint": "dprint 0.40.0",
- "dlint": "dlint 0.52.2",
+ "dlint": "dlint 0.51.0",
};
export const ROOT_PATH = dirname(dirname(fromFileUrl(import.meta.url)));
@@ -155,7 +155,7 @@ export async function getPrebuilt(toolName) {
const toolPath = getPrebuiltToolPath(toolName);
try {
await sanityCheckPrebuiltFile(toolPath);
- const versionOk = await verifyVersion(toolName);
+ const versionOk = await verifyVersion(toolName, toolPath);
if (!versionOk) {
throw new Error("Version mismatch");
}
@@ -185,7 +185,10 @@ export async function downloadPrebuilt(toolName) {
}
const downloadPromise = DOWNLOAD_TASKS[toolName] = deferred();
- const spinner = wait("Downloading prebuilt tool: " + toolName).start();
+ const spinner = wait({
+ text: "Downloading prebuilt tool: " + toolName,
+ interval: 1000,
+ }).start();
const toolPath = getPrebuiltToolPath(toolName);
const tempFile = `${toolPath}.temp`;
@@ -208,6 +211,11 @@ export async function downloadPrebuilt(toolName) {
await resp.body.pipeTo(file.writable);
spinner.text = `Checking prebuilt tool: ${toolName}`;
await sanityCheckPrebuiltFile(tempFile);
+ if (!await verifyVersion(toolName, tempFile)) {
+ throw new Error(
+ "Didn't get the correct version of the tool after downloading.",
+ );
+ }
spinner.text = `Successfully downloaded: ${toolName}`;
await Deno.rename(tempFile, toolPath);
} catch (e) {
@@ -220,14 +228,13 @@ export async function downloadPrebuilt(toolName) {
downloadPromise.resolve(null);
}
-export async function verifyVersion(toolName) {
+export async function verifyVersion(toolName, toolPath) {
const requiredVersion = versions[toolName];
if (!requiredVersion) {
return true;
}
try {
- const toolPath = getPrebuiltToolPath(toolName);
const cmd = new Deno.Command(toolPath, {
args: ["--version"],
stdout: "piped",