check for a hugoVersion package.json field just in case the package version does not and/or cannot align with Hugo in the future (should never happen!)

This commit is contained in:
jake committed 2021-10-09 11:32:48 -04:00
1 parent 0f1844f49e
commit eddc6a62a1
2 files changed
+14 -3

No files matched your search

+10 -1
View File
@@ -2,7 +2,15 @@ import path from "path";
import fs from "fs";
import downloader from "careful-downloader";
import logSymbols from "log-symbols";
import { getPkgVersion, getReleaseUrl, getReleaseFilename, getBinFilename, getBinVersion, getChecksumFilename, isExtended } from "./utils.js";
import {
getPkgVersion,
getReleaseUrl,
getReleaseFilename,
getBinFilename,
getBinVersion,
getChecksumFilename,
isExtended,
} from "./utils.js";
installHugo()
.then((bin) =>
@@ -36,6 +44,7 @@ async function installHugo() {
console.warn(`${logSymbols.info} Hugo Extended isn't supported on this platform, downloading vanilla Hugo instead.`);
}
// download release from GitHub and verify its checksum
const download = await downloader(
getReleaseUrl(version, releaseFile),
getReleaseUrl(version, checksumFile),
+4 -2
View File
@@ -1,10 +1,12 @@
import { readPackageUpSync } from "read-pkg-up";
import { execFileSync } from "child_process";
import { readPackageUpSync } from "read-pkg-up";
// This package's version number (should) always match the Hugo release we want.
// We check for a `hugoVersion` field in package.json just in case it doesn't
// match in the future (from pushing an emergency package update, etc.).
export function getPkgVersion() {
const { packageJson } = readPackageUpSync();
return packageJson.version;
return packageJson.hugoVersion || packageJson.version;
}
// Generate the full GitHub URL to a given release file.