mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-04-26 12:18:29 -04:00
Take over platform/arch detection for more accuracy (#45)
namely for Apple Silicon ARM64 detection on macOS
This commit is contained in:
parent
74d547b698
commit
2b526bec08
24
lib/index.js
24
lib/index.js
@ -2,29 +2,9 @@
|
||||
|
||||
const path = require('path');
|
||||
const BinWrapper = require('bin-wrapper');
|
||||
const { version } = require('../package.json');
|
||||
const src = require('./src');
|
||||
|
||||
const baseUrl = `https://github.com/gohugoio/hugo/releases/download/v${version}/`;
|
||||
|
||||
// Default to extended Hugo, fall back to vanilla Hugo on unsupported platforms
|
||||
module.exports = new BinWrapper()
|
||||
.src(`${baseUrl}hugo_extended_${version}_Linux-64bit.tar.gz`, 'linux', 'x64')
|
||||
.src(`${baseUrl}hugo_extended_${version}_macOS-64bit.tar.gz`, 'darwin', 'x64')
|
||||
.src(`${baseUrl}hugo_extended_${version}_macOS-ARM64.tar.gz`, 'darwin', 'arm64')
|
||||
.src(`${baseUrl}hugo_extended_${version}_Windows-64bit.zip`, 'win32', 'x64')
|
||||
.src(`${baseUrl}hugo_${version}_Linux-32bit.tar.gz`, 'linux', 'x86')
|
||||
.src(`${baseUrl}hugo_${version}_Linux-ARM.tar.gz`, 'linux', 'arm')
|
||||
.src(`${baseUrl}hugo_${version}_Linux-ARM64.tar.gz`, 'linux', 'arm64')
|
||||
.src(`${baseUrl}hugo_${version}_Windows-32bit.zip`, 'win32', 'x86')
|
||||
.src(`${baseUrl}hugo_${version}_FreeBSD-64bit.tar.gz`, 'freebsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${version}_FreeBSD-32bit.tar.gz`, 'freebsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${version}_FreeBSD-ARM.tar.gz`, 'freebsd', 'arm')
|
||||
.src(`${baseUrl}hugo_${version}_NetBSD-64bit.tar.gz`, 'netbsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${version}_NetBSD-32bit.tar.gz`, 'netbsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${version}_NetBSD-ARM.tar.gz`, 'netbsd', 'arm')
|
||||
.src(`${baseUrl}hugo_${version}_OpenBSD-64bit.tar.gz`, 'openbsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${version}_OpenBSD-32bit.tar.gz`, 'openbsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${version}_OpenBSD-ARM.tar.gz`, 'openbsd', 'arm')
|
||||
.src(`${baseUrl}hugo_${version}_DragonFlyBSD-64bit.tar.gz`, 'dragonfly', 'x64')
|
||||
.src(src)
|
||||
.dest(path.join(__dirname, '../vendor'))
|
||||
.use(process.platform === 'win32' ? 'hugo.exe' : 'hugo');
|
||||
|
@ -7,6 +7,6 @@ const bin = require('.');
|
||||
await bin.run(['version']);
|
||||
console.log('✔ Hugo installed successfully!');
|
||||
} catch (error) {
|
||||
console.error('✖ ERROR: Hugo installation failed. :(\n', error);
|
||||
console.error('✖ ERROR: Hugo installation failed. :( Are you sure this platform is supported?\n', error);
|
||||
}
|
||||
})();
|
||||
|
52
lib/src.js
Normal file
52
lib/src.js
Normal file
@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
const { version } = require('../package.json');
|
||||
const baseUrl = `https://github.com/gohugoio/hugo/releases/download/v${version}/`;
|
||||
|
||||
// Platforms: https://nodejs.org/api/process.html#process_process_platform
|
||||
// Architectures: https://nodejs.org/api/process.html#process_process_arch
|
||||
|
||||
// Hugo Extended supports: macOS x64, macOS ARM64, Linux x64, Windows x64.
|
||||
// all other combos fall back to vanilla Hugo.
|
||||
|
||||
/* eslint-disable indent, operator-linebreak, no-multi-spaces, unicorn/no-nested-ternary */
|
||||
module.exports =
|
||||
process.platform === 'darwin' && process.arch === 'x64'
|
||||
? `${baseUrl}hugo_extended_${version}_macOS-64bit.tar.gz` :
|
||||
process.platform === 'darwin' && process.arch === 'arm64'
|
||||
? `${baseUrl}hugo_extended_${version}_macOS-ARM64.tar.gz` :
|
||||
|
||||
process.platform === 'win32' && process.arch === 'x64'
|
||||
? `${baseUrl}hugo_extended_${version}_Windows-64bit.zip` :
|
||||
process.platform === 'win32' && process.arch.endsWith('32')
|
||||
? `${baseUrl}hugo_${version}_Windows-32bit.zip` :
|
||||
|
||||
process.platform === 'linux' && process.arch === 'x64'
|
||||
? `${baseUrl}hugo_extended_${version}_Linux-64bit.tar.gz` :
|
||||
process.platform === 'linux' && process.arch.endsWith('32')
|
||||
? `${baseUrl}hugo_${version}_Linux-32bit.tar.gz` :
|
||||
process.platform === 'linux' && process.arch === 'arm'
|
||||
? `${baseUrl}hugo_${version}_Linux-ARM.tar.gz` :
|
||||
process.platform === 'linux' && process.arch === 'arm64'
|
||||
? `${baseUrl}hugo_${version}_Linux-ARM64.tar.gz` :
|
||||
|
||||
process.platform === 'freebsd' && process.arch === 'x64'
|
||||
? `${baseUrl}hugo_${version}_FreeBSD-64bit.tar.gz` :
|
||||
process.platform === 'freebsd' && process.arch.endsWith('32')
|
||||
? `${baseUrl}hugo_${version}_FreeBSD-32bit.tar.gz` :
|
||||
process.platform === 'freebsd' && process.arch === 'arm'
|
||||
? `${baseUrl}hugo_${version}_FreeBSD-ARM.tar.gz` :
|
||||
process.platform === 'freebsd' && process.arch === 'arm64'
|
||||
? `${baseUrl}hugo_${version}_FreeBSD-ARM64.tar.gz` :
|
||||
|
||||
process.platform === 'openbsd' && process.arch === 'x64'
|
||||
? `${baseUrl}hugo_${version}_OpenBSD-64bit.tar.gz` :
|
||||
process.platform === 'openbsd' && process.arch.endsWith('32')
|
||||
? `${baseUrl}hugo_${version}_OpenBSD-32bit.tar.gz` :
|
||||
process.platform === 'openbsd' && process.arch === 'arm'
|
||||
? `${baseUrl}hugo_${version}_OpenBSD-ARM.tar.gz` :
|
||||
process.platform === 'openbsd' && process.arch === 'arm64'
|
||||
? `${baseUrl}hugo_${version}_OpenBSD-ARM64.tar.gz` :
|
||||
|
||||
null;
|
||||
/* eslint-enable indent, operator-linebreak, no-multi-spaces, unicorn/no-nested-ternary */
|
1174
package-lock.json
generated
1174
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"bin-check": "^4.1.0",
|
||||
"mocha": "^8.3.0",
|
||||
"xo": "^0.38.1"
|
||||
"mocha": "^8.3.2",
|
||||
"xo": "^0.38.2"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node lib/install.js",
|
||||
|
Loading…
x
Reference in New Issue
Block a user