Chore: simplify build infra / remove reject_phishing

This commit is contained in:
SukkaW
2023-12-09 23:23:55 +08:00
parent 42e9b4310f
commit 1928c052a9
24 changed files with 259 additions and 332 deletions

View File

@@ -1,19 +1,21 @@
import path from 'path';
import picocolors from 'picocolors';
const traceSync = <T>(prefix: string, fn: () => T): T => {
function traceSync<T>(prefix: string, fn: () => T): T {
const start = Bun.nanoseconds();
const result = fn();
const end = Bun.nanoseconds();
console.log(`${prefix}: ${((end - start) / 1e6).toFixed(3)}ms`);
console.log(`${picocolors.gray(`[${((end - start) / 1e6).toFixed(3)}ms]`)} ${prefix}`);
return result;
};
}
traceSync.skip = <T>(prefix: string, fn: () => T): T => fn();
export { traceSync };
const traceAsync = async <T>(prefix: string, fn: () => Promise<T>): Promise<T> => {
const start = Bun.nanoseconds();
const result = await fn();
const end = Bun.nanoseconds();
console.log(`${prefix}: ${((end - start) / 1e6).toFixed(3)}ms`);
console.log(`${picocolors.gray(`[${((end - start) / 1e6).toFixed(3)}ms]`)} ${prefix}`);
return result;
};
export { traceAsync };
@@ -31,7 +33,7 @@ const task = <T>(importMetaPath: string, fn: () => Promise<T>, customname: strin
const start = Bun.nanoseconds();
await fn();
const end = Bun.nanoseconds();
console.log(`✅ [${taskName}] Executed successfully: ${((end - start) / 1e6).toFixed(3)}ms`);
console.log(`✅ [${taskName}] [${((end - start) / 1e6).toFixed(3)}ms] Executed successfully`);
return { start, end, taskName } as TaskResult;
};