summaryrefslogtreecommitdiff
path: root/modules/blog/blog.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/blog/blog.js')
-rw-r--r--modules/blog/blog.js24
1 files changed, 5 insertions, 19 deletions
diff --git a/modules/blog/blog.js b/modules/blog/blog.js
index a866003..3985fdb 100644
--- a/modules/blog/blog.js
+++ b/modules/blog/blog.js
@@ -4,6 +4,7 @@ const https = require("https");
const child_process = require("child_process");
const generateTemplate = require("./template.js");
+const blogUtil = require("./util.js");
let moddir = null;
let repodir = null;
@@ -50,32 +51,17 @@ function fetch(url) {
});
}
-function runCommand(cmd, args) {
- console.log(`blog: ${cmd} ${JSON.stringify(args)}`);
- child_process.execFileSync(
- cmd, args,
- { stdio: "inherit", timeout: 20000 }
- );
-}
-
-function runCommandOutput(cmd, args) {
- return child_process.execFileSync(
- cmd, args,
- { timeout: 20000 }
- );
-}
-
function ensureRepo() {
try {
const stats = fs.statSync(repodir);
if (stats.isDirectory()) return;
} catch (e) {}
- runCommand("git", ["clone", "https://git.tomsmeding.com/blog", repodir]);
+ blogUtil.runCommand("git", ["clone", "https://git.tomsmeding.com/blog", repodir]);
}
function currentCommit() {
- return runCommandOutput("git", ["-C", repodir, "rev-parse", "HEAD"]).toString().trim();
+ return blogUtil.runCommandOutput("git", ["-C", repodir, "rev-parse", "HEAD"], { silent: true }).toString().trim();
}
async function upstreamCommit() {
@@ -85,8 +71,8 @@ async function upstreamCommit() {
function updateRepo() {
try {
- runCommand("git", ["-C", repodir, "fetch", "--all"]);
- runCommand("git", ["-C", repodir, "reset", "origin/master", "--hard"]);
+ blogUtil.runCommand("git", ["-C", repodir, "fetch", "--all"]);
+ blogUtil.runCommand("git", ["-C", repodir, "reset", "origin/master", "--hard"]);
// Reset cache _after_ the commands succeeded; if anything failed, we
// might at least still have stale cache data
templateCache = new Map();