mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-11 09:11:50 +00:00
27 lines
858 B
JavaScript
27 lines
858 B
JavaScript
import { execSync } from "child_process";
|
|
import fs from "fs";
|
|
import glob from "glob";
|
|
|
|
export function getRevision(useLast = false) {
|
|
const commitHash = execSync("git rev-parse --short " + (useLast ? "HEAD^1" : "HEAD")).toString("ascii");
|
|
return commitHash.replace(/^\s+|\s+$/g, "");
|
|
}
|
|
|
|
export function getAllResourceImages() {
|
|
return glob
|
|
.sync("res/**/*.@(png|svg|jpg)", { cwd: ".." })
|
|
.map(f => f.replace(/^res\//gi, ""))
|
|
.filter(f => {
|
|
if (f.indexOf("ui") >= 0) {
|
|
// We drop all ui images except for the noinline ones
|
|
return f.indexOf("noinline") >= 0;
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
export function getVersion() {
|
|
// Use the version number specified in package.json
|
|
return JSON.parse(fs.readFileSync("../package.json", "utf-8")).version;
|
|
}
|