From 556a676801eef44382bfdfe7700e5d9e1b049ea2 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 29 May 2023 09:18:33 +0300 Subject: [PATCH] Add debug info with `NODE_DEBUG=hugo-bin` --- lib/index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/index.js b/lib/index.js index 8a18d71..8fa5543 100644 --- a/lib/index.js +++ b/lib/index.js @@ -2,9 +2,12 @@ import fs from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; import { fileURLToPath } from 'node:url'; +import { debuglog } from 'node:util'; import BinWrapper from '@xhmikosr/bin-wrapper'; import { packageConfig } from 'pkg-conf'; +const debug = debuglog('hugo-bin'); + const pkg = new URL('../package.json', import.meta.url); const { hugoVersion } = JSON.parse(await fs.readFile(pkg, 'utf8')); @@ -60,7 +63,25 @@ async function main(cwd) { ].includes('extended'); const baseUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`; + debugInfo({ config, downloadRepo, isExtended, baseUrl }); + return isExtended ? extendedBin(baseUrl) : normalBin(baseUrl); } +function debugInfo({ config, downloadRepo, isExtended, baseUrl }) { + debug(`process.env.HUGO_BIN_DOWNLOAD_REPO: ${process.env.HUGO_BIN_DOWNLOAD_REPO || '(empty)'}`); + debug(`process.env.npm_config_hugo_bin_download_repo: ${process.env.npm_config_hugo_bin_download_repo || '(empty)'}`); + debug(`config.downloadRepo: ${config.downloadRepo || '(empty)'}`); + debug(`process.env.HUGO_BIN_BUILD_TAGS: ${process.env.HUGO_BIN_BUILD_TAGS || '(empty)'}`); + debug(`process.env.npm_config_hugo_bin_build_tags: ${process.env.npm_config_hugo_bin_build_tags || '(empty)'}`); + debug(`config.buildTags: ${config.buildTags || '(empty)'}`); + + debug(`hugoVersion: ${hugoVersion}`); + debug(`destDir: ${destDir}`); + debug(`binName: ${binName}`); + debug(`downloadRepo: ${downloadRepo}`); + debug(`isExtended: ${isExtended}`); + debug(`baseUrl: ${baseUrl}`); +} + export default main;