1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2025-09-15 22:35:31 -04:00

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:
2021-10-09 11:32:48 -04:00
parent 0f1844f49e
commit eddc6a62a1
2 changed files with 15 additions and 4 deletions

View File

@@ -2,12 +2,20 @@ 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) =>
// try querying hugo's version via CLI
getBinVersion(bin),
getBinVersion(bin),
)
.then((version) => {
// print output of `hugo version` to console
@@ -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),

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.