mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
This consolidates duplicate functions that were scattered across the codebase: 1. **Platform detection functions** (isWindows, isLinux, isMacOS, isPosix) - Created internal/platform.ts module for built-in JS modules - Updated test files to import from harness instead of redefining 2. **Patch test snapshot normalization** - Created harness-patch.ts for shared normalizeBunSnapshotForPatch - Consolidated identical implementations from 2 test files 3. **Removed inline isLinux redefinition** - net.ts was defining isLinux twice, now uses shared import Files affected: - src/js/internal/platform.ts (new shared module) - src/js/internal/fs/glob.ts (use shared isWindows) - src/js/node/net.ts (use shared isWindows and isLinux) - test/harness-patch.ts (new shared test utility) - test/cli/install/bun-install-patch.test.ts - test/regression/issue/patch-bounds-check.test.ts - test/js/node/test/common/index.js - test/napi/node-napi-tests/test/common/index.js 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
12 lines
454 B
TypeScript
12 lines
454 B
TypeScript
import { normalizeBunSnapshot as normalizeBunSnapshotBase } from "./harness";
|
|
|
|
/**
|
|
* Normalize Bun snapshot output for patch-related tests
|
|
* Removes package resolution messages and normalizes fstatat() to stat()
|
|
*/
|
|
export const normalizeBunSnapshotForPatch = (str: string) => {
|
|
str = normalizeBunSnapshotBase(str);
|
|
str = str.replace(/.*Resolved, downloaded and extracted.*\n?/g, "");
|
|
str = str.replaceAll("fstatat()", "stat()");
|
|
return str;
|
|
}; |