Skip to content

Commit

Permalink
Fixed CI not being run on CI and cleaned up build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Dec 20, 2024
1 parent 116cdb5 commit b410325
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Christopher-Robin <[email protected]>",
"license": "GPL-2.0",
"scripts": {
"prebuild": "exec node --no-warnings=ExperimentalWarning util/versioning.mjs update package.json lib/package.json",
"prebuild": "(node --no-warnings=ExperimentalWarning util/ci.mjs) && (node --no-warnings=ExperimentalWarning util/versioning.mjs update package.json lib/package.json)",
"build": "shx rm -rf dist && rollup -c",
"bundle": "shx rm -rf dist && rollup -c",
"watch": "rollup -c -w",
Expand Down
5 changes: 3 additions & 2 deletions util/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Logger } from './log.mjs';
import { exit } from 'process';

import plugin from "../plugin.json" with { type: "json" };
import { IsCI, SetEnvironment } from './ci.mjs';
const { name: PluginName } = plugin;

if (process.argv.includes('-h') || process.argv.includes('--help')) {
Expand Down Expand Up @@ -96,9 +97,9 @@ async function importJson(file) {
return (await import(file, { with: { type: "json" } })).default;
}

if (env["CI"]) {
if (IsCI()) {
Logger.Log("Running CI related setup");
runCommand("git config --global --add safe.directory /plugin");
SetEnvironment();
}
if (!quiet)
Logger.Log(`Building plugin ${PluginName}@${Version}`);
Expand Down
7 changes: 4 additions & 3 deletions util/versioning.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFileSync, writeFileSync, utimesSync, statSync } from "fs";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import { Logger } from "./log.mjs";

export const Version = ReadPackageVersion();
function ReadPackageVersion() {
Expand Down Expand Up @@ -52,15 +53,15 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {

switch (process.argv[2]) {
case "reset":
console.log(`Resetting ${files.join(", ")}`);
Logger.Info(`Resetting ${files.join(", ")}`);
ResetVersion(...files);
break;
case "update":
console.log(`Updating ${files.join(", ")} to version ${Version}`);
Logger.Info(`Updating ${files.join(", ")} to version ${Version}`);
UpdateVersion(...files);
break;
default:
console.log("Invalid argument provided. Must be one of 'reset' | 'update'");
Logger.Info("Invalid argument provided. Must be one of 'reset' | 'update'");
process.exit(1);
}
}

0 comments on commit b410325

Please sign in to comment.