You've already forked hugo-extended
mirror of
https://github.com/jakejarvis/hugo-extended.git
synced 2025-07-19 09:45:30 -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:
@@ -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