mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-04-27 04:38:25 -04:00
Rename variables
This commit is contained in:
parent
1e4307eaf9
commit
e69a92ad0e
@ -19,9 +19,9 @@ npm install hugo-bin --save-dev
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
import { execFile } from 'node:child_process';
|
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) {
|
if (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import hugo from '../index.js';
|
import hugoPath from '../index.js';
|
||||||
|
|
||||||
const input = process.argv.slice(2);
|
const input = process.argv.slice(2);
|
||||||
|
|
||||||
spawn(hugo, input, { stdio: 'inherit' })
|
spawn(hugoPath, input, { stdio: 'inherit' })
|
||||||
.on('exit', process.exit);
|
.on('exit', process.exit);
|
||||||
|
7
index.js
7
index.js
@ -1,6 +1,7 @@
|
|||||||
import process from 'node:process';
|
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;
|
||||||
|
@ -42,8 +42,8 @@ const normalBin = baseDownloadUrl => new BinWrapper()
|
|||||||
.dest(destDir)
|
.dest(destDir)
|
||||||
.use(binName);
|
.use(binName);
|
||||||
|
|
||||||
async function main(projectRoot) {
|
async function main(cwd) {
|
||||||
const config = await packageConfig('hugo-bin', { cwd: projectRoot });
|
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 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 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}/`;
|
const baseDownloadUrl = `${downloadRepo}/gohugoio/hugo/releases/download/v${hugoVersion}/`;
|
||||||
|
@ -2,13 +2,13 @@ import process from 'node:process';
|
|||||||
import binCheck from 'bin-check';
|
import binCheck from 'bin-check';
|
||||||
import { suite } from 'uvu';
|
import { suite } from 'uvu';
|
||||||
import * as assert from 'uvu/assert'; // eslint-disable-line n/file-extension-in-import
|
import * as assert from 'uvu/assert'; // eslint-disable-line n/file-extension-in-import
|
||||||
import hugoBin from '../index.js';
|
import hugoPath from '../index.js';
|
||||||
import hugoLib from '../lib/index.js';
|
import hugoBin from '../lib/index.js';
|
||||||
|
|
||||||
const worksSuite = suite('works');
|
const worksSuite = suite('works');
|
||||||
|
|
||||||
worksSuite('should return path to binary and work', async() => {
|
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);
|
assert.is(works, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ customRepoSuite('verify test env', () => {
|
|||||||
|
|
||||||
// Default Repository - Test Cases
|
// Default Repository - Test Cases
|
||||||
customRepoSuite('should return default repository url - Repository: default - Extended: undefined', async() => {
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
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() => {
|
customRepoSuite('should return default repository url - Repository: default - Extended: empty', async() => {
|
||||||
process.env.npm_config_hugo_bin_build_tags = '';
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
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() => {
|
customRepoSuite('should return default repository url - Repository: default - Extended: extended', async() => {
|
||||||
process.env.npm_config_hugo_bin_build_tags = 'extended';
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
for (const sourceUrl of repoSources) {
|
||||||
@ -63,7 +63,7 @@ customRepoSuite('should return default repository url - Repository: default - Ex
|
|||||||
// Custom/Enterprise Repository Test Cases
|
// Custom/Enterprise Repository Test Cases
|
||||||
customRepoSuite('should return custom repository url - Repository: custom - Extended: undefined', async() => {
|
customRepoSuite('should return custom repository url - Repository: custom - Extended: undefined', async() => {
|
||||||
process.env.npm_config_hugo_bin_download_repo = 'https://some1.example.com';
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
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() => {
|
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_build_tags = '';
|
||||||
process.env.npm_config_hugo_bin_download_repo = 'https://some2.example.com';
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
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() => {
|
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_build_tags = 'extended';
|
||||||
process.env.npm_config_hugo_bin_download_repo = 'https://some3.example.com';
|
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);
|
const repoSources = lib._src.map(v => v.url);
|
||||||
|
|
||||||
for (const sourceUrl of repoSources) {
|
for (const sourceUrl of repoSources) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user