forked from fenneclab/hugo-bin
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
22 lines (18 loc) · 740 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import logSymbols from "log-symbols";
import install from "./lib/install.js";
import { getBinPath, doesBinExist } from "./lib/utils.js";
const hugo = async () => {
const bin = getBinPath();
// A fix for fleeting ENOENT errors, where Hugo seems to disappear. For now,
// just reinstall Hugo when it's missing and then continue normally like
// nothing happened.
// See: https://github.com/jakejarvis/hugo-extended/issues/81
if (!doesBinExist(bin)) {
// Hugo isn't there for some reason. Try re-installing.
console.info(`${logSymbols.info} Hugo is missing, reinstalling now...`);
await install();
}
return bin;
};
// The only thing this module really exports is the absolute path to Hugo:
export default hugo;