1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2025-04-26 21:38:26 -04:00
hugo-extended/test/index.spec.js
2024-06-04 11:50:38 -04:00

37 lines
973 B
JavaScript

/* eslint-env node, mocha */
import path from "path";
import { execFile } from "child_process";
import assert from "assert";
import { deleteAsync } from "del";
import hugo from "../index.js";
import { getBinPath } from "../lib/utils.js";
it("Hugo exists and runs?", async function () {
this.timeout(30000); // increase timeout to an excessive 30 seconds for CI
const hugoPath = await hugo();
assert(execFile(hugoPath, ["env"], function (error, stdout) {
if (error)
throw error;
console.log(stdout);
}));
});
it("Hugo doesn't exist, install it instead of throwing an error", async function () {
this.timeout(30000); // increase timeout to an excessive 30 seconds for CI
// delete binary to ensure it's auto-reinstalled
await deleteAsync(path.dirname(getBinPath()));
const hugoPath = await hugo();
assert(execFile(hugoPath, ["version"], function (error, stdout) {
if (error)
throw error;
console.log(stdout);
}));
});