You've already forked hugo-extended
mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-07-03 14:36:38 -04:00
Support Hugo extended (#65)
* wip: Support Hugo extended * fallback support, update readme.md * fixup! wip: Support Hugo extended
This commit is contained in:
26
lib/index.js
26
lib/index.js
@ -1,5 +1,6 @@
|
||||
const path = require('path');
|
||||
const BinWrapper = require('bin-wrapper');
|
||||
const pkgConf = require('pkg-conf');
|
||||
const pkg = require('../package');
|
||||
|
||||
const hugoVersion = pkg.hugoVersion;
|
||||
@ -29,9 +30,23 @@ const binNameMap = {
|
||||
x64: 'hugo.exe'
|
||||
}
|
||||
};
|
||||
const dest = path.join(__dirname, '../vendor');
|
||||
const binName = (binNameMap[process.platform] && binNameMap[process.platform][process.arch]) || '';
|
||||
|
||||
module.exports = new BinWrapper()
|
||||
const extendedBin = new BinWrapper()
|
||||
.src(`${baseUrl}hugo_extended_${hugoVersion}_Linux-64bit.tar.gz`, 'linux', 'x64')
|
||||
.src(`${baseUrl}hugo_extended_${hugoVersion}_macOS-64bit.tar.gz`, 'darwin', 'x64')
|
||||
.src(`${baseUrl}hugo_extended_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
|
||||
// Falling back to normal version on non supported platforms
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-32bit.tar.gz`, 'freebsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-64bit.tar.gz`, 'freebsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-ARM.tar.gz`, 'freebsd', 'arm')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Linux-32bit.tar.gz`, 'linux', 'x86')
|
||||
.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)
|
||||
.use(binName);
|
||||
const normalBin = new BinWrapper()
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-32bit.tar.gz`, 'freebsd', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-64bit.tar.gz`, 'freebsd', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_FreeBSD-ARM.tar.gz`, 'freebsd', 'arm')
|
||||
@ -42,5 +57,10 @@ module.exports = new BinWrapper()
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_macOS-64bit.tar.gz`, 'darwin', 'x64')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Windows-32bit.zip`, 'win32', 'x86')
|
||||
.src(`${baseUrl}hugo_${hugoVersion}_Windows-64bit.zip`, 'win32', 'x64')
|
||||
.dest(path.join(__dirname, '../vendor'))
|
||||
.dest(dest)
|
||||
.use(binName);
|
||||
module.exports = projectRoot => {
|
||||
const config = pkgConf.sync('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;
|
||||
};
|
||||
|
@ -1,7 +1,26 @@
|
||||
const path = require('path');
|
||||
const bin = require('./');
|
||||
const log = require('logalot');
|
||||
|
||||
bin.run(['version'])
|
||||
function getProjectRoot() {
|
||||
// projectRoot on postinstall could be INIT_CWD introduced in npm>=5.4
|
||||
// see: https://github.com/npm/npm/issues/16990
|
||||
const initCwd = process.env.INIT_CWD;
|
||||
if (initCwd) {
|
||||
return initCwd;
|
||||
}
|
||||
// Fallback of getting INIT_CWD
|
||||
const cwd = process.cwd();
|
||||
const paths = cwd.split(path.sep);
|
||||
// If process.cwd end with 'node_modules/*' then get the dependent root directory,
|
||||
// otherwise returns cwd (ordinary it will be the postinstall process of hugo-bin itself).
|
||||
if (paths.length > 1 && paths[paths.length - 2] === 'node_modules') {
|
||||
return path.resolve('../../', cwd);
|
||||
}
|
||||
return cwd;
|
||||
}
|
||||
|
||||
bin(getProjectRoot()).run(['version'])
|
||||
.then(() => {
|
||||
log.success('Hugo binary is installed successfully');
|
||||
})
|
||||
|
Reference in New Issue
Block a user