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

lib/index.js: simplify code

We only need the file extension on Windows and the other part is always the same: "hugo".
This commit is contained in:
XhmikosR
2021-11-03 08:24:00 +02:00
parent 7e1e17b6f1
commit 8dd300b9a8

View File

@ -6,49 +6,8 @@ const pkgConf = require('pkg-conf');
const { hugoVersion } = require('../package.json');
const baseUrl = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/`;
const binNameMap = {
darwin: {
arm64: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
freebsd: {
arm: 'hugo',
arm64: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
linux: {
arm: 'hugo',
arm64: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
netbsd: {
arm: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
openbsd: {
arm: 'hugo',
arm64: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
android: {
arm: 'hugo',
ia32: 'hugo',
x64: 'hugo'
},
win32: {
ia32: 'hugo.exe',
x64: 'hugo.exe'
}
};
const dest = path.join(__dirname, '../vendor');
const binName = (binNameMap[process.platform] && binNameMap[process.platform][process.arch]) || '';
const destDir = path.join(__dirname, '../vendor/');
const binName = process.platform === 'win32' ? 'hugo.exe' : 'hugo';
const extendedBin = new BinWrapper()
.src(`${baseUrl}hugo_extended_${hugoVersion}_Linux-64bit.tar.gz`, 'linux', 'x64')
@ -63,7 +22,7 @@ const extendedBin = new BinWrapper()
.src(`${baseUrl}hugo_${hugoVersion}_Linux-ARM.tar.gz`, 'linux', 'arm')
.src(`${baseUrl}hugo_${hugoVersion}_macOS-32bit.tar.gz`, 'darwin', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
.dest(dest)
.dest(destDir)
.use(binName);
const normalBin = new BinWrapper()
@ -87,7 +46,7 @@ const normalBin = new BinWrapper()
.src(`${baseUrl}hugo_${hugoVersion}_OpenBSD-ARM64.tar.gz`, 'openbsd', 'arm64')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
.src(`${baseUrl}hugo_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
.dest(dest)
.dest(destDir)
.use(binName);
module.exports = projectRoot => {