|
| 1 | +# Windows Compatibility Improvements |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Made the codebase Windows-compatible by fixing path handling issues that would cause problems on Windows systems due to hardcoded forward slashes and string concatenation for paths. |
| 6 | + |
| 7 | +## Changes Made |
| 8 | + |
| 9 | +### 1. Fixed Default Output Directory Path |
| 10 | +**File:** `/workspace/packages/proto-parser/src/options/defaults.ts` |
| 11 | + |
| 12 | +**Before:** |
| 13 | +```typescript |
| 14 | +outDir: `${process.cwd()}/out`, |
| 15 | +``` |
| 16 | + |
| 17 | +**After:** |
| 18 | +```typescript |
| 19 | +import { join } from 'path'; |
| 20 | +// ... |
| 21 | +outDir: join(process.cwd(), 'out'), |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. Fixed Glob Pattern in Test Utils |
| 25 | +**File:** `/workspace/packages/proto-parser/test-utils/index.ts` |
| 26 | + |
| 27 | +**Before:** |
| 28 | +```typescript |
| 29 | +glob(outDir + '**/*') |
| 30 | +``` |
| 31 | + |
| 32 | +**After:** |
| 33 | +```typescript |
| 34 | +glob(join(outDir, '**/*')) |
| 35 | +``` |
| 36 | + |
| 37 | +### 3. Fixed Glob Patterns in Deparser Scripts |
| 38 | +**Files:** |
| 39 | +- `/workspace/packages/deparser/scripts/make-fixtures-sql.ts` |
| 40 | +- `/workspace/packages/deparser/scripts/make-fixtures-ast.ts` |
| 41 | +- `/workspace/packages/deparser/scripts/make-fixtures.ts` |
| 42 | +- `/workspace/packages/deparser/scripts/make-kitchen-sink.ts` |
| 43 | + |
| 44 | +**Before:** |
| 45 | +```typescript |
| 46 | +const fixtures = globSync(`${FIXTURE_DIR}/**/*.sql`); |
| 47 | +``` |
| 48 | + |
| 49 | +**After:** |
| 50 | +```typescript |
| 51 | +const fixtures = globSync(path.join(FIXTURE_DIR, '**/*.sql')); |
| 52 | +``` |
| 53 | + |
| 54 | +## Why These Changes Matter |
| 55 | + |
| 56 | +1. **Cross-Platform Compatibility**: Using `path.join()` ensures that the correct path separator is used for each operating system (forward slash on Unix-like systems, backslash on Windows). |
| 57 | + |
| 58 | +2. **Glob Pattern Compatibility**: While glob patterns typically use forward slashes even on Windows, using `path.join()` ensures consistency and prevents potential issues with path resolution. |
| 59 | + |
| 60 | +3. **Future-Proof**: These changes make the codebase more maintainable and prevent future Windows-related issues. |
| 61 | + |
| 62 | +## Verification |
| 63 | + |
| 64 | +All existing path operations in the codebase were already using proper Node.js path module functions: |
| 65 | +- `mkdirSync` with `{ recursive: true }` for directory creation |
| 66 | +- `path.join()`, `path.resolve()`, `path.dirname()`, `path.basename()` for path manipulation |
| 67 | +- `readFileSync` and `writeFileSync` for file operations |
| 68 | + |
| 69 | +## No Breaking Changes |
| 70 | + |
| 71 | +These changes are purely internal and do not affect the public API or behavior of the packages. All functionality remains the same across all platforms. |
0 commit comments