You've already forked hugo-extended
mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-07-19 09:45:30 -04:00
Switch to ESM
This commit is contained in:
23
lib/index.js
23
lib/index.js
@@ -1,12 +1,14 @@
|
||||
'use strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import BinWrapper from 'bin-wrapper';
|
||||
import { packageConfigSync } from 'pkg-conf';
|
||||
|
||||
const path = require('path');
|
||||
const BinWrapper = require('bin-wrapper');
|
||||
const pkgConf = require('pkg-conf');
|
||||
const { hugoVersion } = require('../package.json');
|
||||
const { hugoVersion } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
|
||||
|
||||
const baseUrl = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/`;
|
||||
const destDir = path.join(__dirname, '../vendor/');
|
||||
const destDir = path.join(fileURLToPath(new URL('../vendor', import.meta.url)));
|
||||
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
|
||||
|
||||
const extendedBin = new BinWrapper()
|
||||
@@ -44,8 +46,11 @@ const normalBin = new BinWrapper()
|
||||
.dest(destDir)
|
||||
.use(binName);
|
||||
|
||||
module.exports = projectRoot => {
|
||||
const config = pkgConf.sync('hugo-bin', { cwd: projectRoot });
|
||||
function main(projectRoot) {
|
||||
const config = packageConfigSync('hugo-bin', { cwd: projectRoot });
|
||||
const extended = (process.env.HUGO_BIN_BUILD_TAGS || process.env.npm_config_hugo_bin_build_tags || config.buildTags) === 'extended';
|
||||
|
||||
return extended ? extendedBin : normalBin;
|
||||
};
|
||||
}
|
||||
|
||||
export default main;
|
||||
|
Reference in New Issue
Block a user