1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-09 16:21:51 +00:00
tobspr_shapez.io/gulp/buildutils.js
EmeraldBlock 24ceb6664d ES modules and config refactor
- switches to ES modules in gulp and src
- uses dengr's webpack configs and package.json, with modifications
- removes gulp/package.json
- removes babel stuff
- removes gulp-load-plugins, instead importing gulp plugins manually
- removes unused and trivial packages
- upgrades packages
- uses path/posix, for gulp
- removes __dirname in favor of relative urls
2023-03-04 00:46:55 -06:00

43 lines
1.2 KiB
JavaScript

import glob from "glob";
import { execSync } from "child_process";
import fs from "fs";
import path from "path/posix";
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 getTag() {
try {
return execSync("git describe --tag --exact-match").toString("ascii");
} catch (e) {
throw new Error("Current git HEAD is not a version tag");
}
}
export function getVersion() {
return fs.readFileSync(path.join("..", "version")).toString().trim();
}
/**
* @param {string} url
* @param {string} commitHash
*/
export function cachebust(url, commitHash) {
return "/v/" + commitHash + "/" + url;
}