Skip to content

Commit

Permalink
Add debug info with NODE_DEBUG=hugo-bin
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jun 30, 2023
1 parent 5d9c92f commit 556a676
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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;

0 comments on commit 556a676

Please sign in to comment.