Bladeren bron

ref: logging in cli tools

Sv443 3 maanden geleden
bovenliggende
commit
d6059d4eaf
2 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 11 1
      tools/fix-dts.mts
  2. 2 1
      tools/post-build-global.mts

+ 11 - 1
tools/fix-dts.mts

@@ -1,5 +1,8 @@
 import { readdir, readFile, writeFile, lstat } from "node:fs/promises";
 import { join, resolve } from "node:path";
+import k from "kleur";
+
+const dtsPath = resolve("./dist/lib/");
 
 /** Adds two spaces to the end of each line in JSDoc comments to preserve the meticulous line breaks */
 async function addTrailingSpaces(filePath: string) {
@@ -30,4 +33,11 @@ async function processRecursive(directory: string) {
   }
 }
 
-processRecursive("./dist/lib");
+try {
+  await processRecursive(dtsPath);
+
+  console.log(k.green(`Fixed all .d.ts files in ${k.reset(`'${dtsPath}'`)}`));
+}
+catch(err) {
+  console.error(k.red(`Encountered error while fixing .d.ts files in ${k.reset(`'${dtsPath}'`)}:\n`), err);
+}

+ 2 - 1
tools/post-build-global.mts

@@ -1,5 +1,6 @@
 import { access, constants as fsconstants, readFile, writeFile } from "node:fs/promises";
 import { resolve } from "node:path";
+import k from "kleur";
 import pkg from "../package.json" with { type: "json" };
 
 const { exit } = process;
@@ -43,7 +44,7 @@ async function run() {
     .replace(/^\s*'use strict';\s*(\r?\n){1,2}/gm, "");
 
   await writeFile(iifeBundlePath, finalBundle, "utf8");
-  console.log(`\x1b[32mGlobal bundle at path \x1b[0m'${iifeBundlePath}'\x1b[32m has been updated\x1b[0m`);
+  console.log(k.green(`Successfully updated global bundle at path ${k.reset(`'${iifeBundlePath}'`)}\n`));
 
   setImmediate(() => exit(0));
 }