1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2025-04-26 13:28:28 -04:00

Rename variables

This commit is contained in:
XhmikosR 2023-05-17 08:15:38 +03:00
parent 1e4307eaf9
commit e69a92ad0e
5 changed files with 19 additions and 18 deletions

View File

@ -19,9 +19,9 @@ npm install hugo-bin --save-dev
```js
import { execFile } from 'node:child_process';
import hugo from 'hugo-bin';
import hugoPath from 'hugo-bin';
execFile(hugo, ['version'], (error, stdout) => {
execFile(hugoPath, ['version'], (error, stdout) => {
if (error) {
throw error;
}

View File

@ -2,9 +2,9 @@
import { spawn } from 'node:child_process';
import process from 'node:process';
import hugo from '../index.js';
import hugoPath from '../index.js';
const input = process.argv.slice(2);
spawn(hugo, input, { stdio: 'inherit' })
spawn(hugoPath, input, { stdio: 'inherit' })
.on('exit', process.exit);

View File

@ -1,6 +1,7 @@
import process from 'node:process';
import lib from './lib/index.js';
import hugoBin from './lib/index.js';
const hugoBin = await lib(process.cwd());
const bin = await hugoBin(process.cwd());
const hugoPath = bin.path();
export default hugoBin.path();
export default hugoPath;

View File

@ -42,8 +42,8 @@ const normalBin = baseDownloadUrl => new BinWrapper()
.dest(destDir)
.use(binName);
async function main(projectRoot) {
const config = await packageConfig('hugo-bin', { cwd: projectRoot });
async function main(cwd) {
const config = await packageConfig('hugo-bin', { cwd });
const extended = (process.env.HUGO_BIN_BUILD_TAGS || process.env.npm_config_hugo_bin_build_tags || config.buildTags) === 'extended';
const downloadRepo = process.env.HUGO_BIN_DOWNLOAD_REPO || process.env.npm_config_hugo_bin_download_repo || config.downloadRepo || 'https://github.com';
const baseDownloadUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;

View File

@ -2,13 +2,13 @@ import process from 'node:process';
import binCheck from 'bin-check';
import { suite } from 'uvu';
import * as assert from 'uvu/assert'; // eslint-disable-line n/file-extension-in-import
import hugoBin from '../index.js';
import hugoLib from '../lib/index.js';
import hugoPath from '../index.js';
import hugoBin from '../lib/index.js';
const worksSuite = suite('works');
worksSuite('should return path to binary and work', async() => {
const works = await binCheck(hugoBin, ['version']);
const works = await binCheck(hugoPath, ['version']);
assert.is(works, true);
});
@ -32,7 +32,7 @@ customRepoSuite('verify test env', () => {
// Default Repository - Test Cases
customRepoSuite('should return default repository url - Repository: default - Extended: undefined', async() => {
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {
@ -42,7 +42,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
customRepoSuite('should return default repository url - Repository: default - Extended: empty', async() => {
process.env.npm_config_hugo_bin_build_tags = '';
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {
@ -52,7 +52,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
customRepoSuite('should return default repository url - Repository: default - Extended: extended', async() => {
process.env.npm_config_hugo_bin_build_tags = 'extended';
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {
@ -63,7 +63,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
// Custom/Enterprise Repository Test Cases
customRepoSuite('should return custom repository url - Repository: custom - Extended: undefined', async() => {
process.env.npm_config_hugo_bin_download_repo = 'https://some1.example.com';
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {
@ -74,7 +74,7 @@ customRepoSuite('should return custom repository url - Repository: custom - Exte
customRepoSuite('should return custom repository url - Repository: custom - Extended: empty', async() => {
process.env.npm_config_hugo_bin_build_tags = '';
process.env.npm_config_hugo_bin_download_repo = 'https://some2.example.com';
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {
@ -85,7 +85,7 @@ customRepoSuite('should return custom repository url - Repository: custom - Exte
customRepoSuite('should return custom repository url - Repository: custom - Extended: extended', async() => {
process.env.npm_config_hugo_bin_build_tags = 'extended';
process.env.npm_config_hugo_bin_download_repo = 'https://some3.example.com';
const lib = await hugoLib(process.cwd());
const lib = await hugoBin(process.cwd());
const repoSources = lib._src.map(v => v.url);
for (const sourceUrl of repoSources) {