mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
fix(sdk-options): normalize paths for cross-platform cloud storage detection
Fixed cloud storage path detection to work correctly on Windows by normalizing path separators to forward slashes and removing Windows drive letters before pattern matching. Issue: The isCloudStoragePath() function was failing on Windows because: 1. path.resolve() converts Unix paths to Windows paths with backslashes 2. Windows adds drive letters (e.g., "P:\Users\test" instead of "/Users/test") 3. Pattern checks for "/Library/CloudStorage/" didn't match "\Library\CloudStorage\" 4. Home-anchored path comparisons failed due to drive letter mismatches Solution: - Normalize all path separators to forward slashes for consistent pattern matching - Remove Windows drive letters (e.g., "C:" or "P:") from normalized paths - This ensures Unix-style test paths work the same on all platforms All tests now pass (967 passed, 27 skipped): - ✅ Cloud storage path detection tests (macOS patterns) - ✅ Home-anchored cloud folder tests (Dropbox, Google Drive, OneDrive) - ✅ Sandbox compatibility tests - ✅ Cross-platform path handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,9 +99,14 @@ const HOME_ANCHORED_CLOUD_FOLDERS = [
|
||||
*/
|
||||
export function isCloudStoragePath(cwd: string): boolean {
|
||||
const resolvedPath = path.resolve(cwd);
|
||||
// Normalize to forward slashes for consistent pattern matching across platforms
|
||||
let normalizedPath = resolvedPath.split(path.sep).join('/');
|
||||
// Remove Windows drive letter if present (e.g., "C:/Users" -> "/Users")
|
||||
// This ensures Unix paths in tests work the same on Windows
|
||||
normalizedPath = normalizedPath.replace(/^[A-Za-z]:/, '');
|
||||
|
||||
// Check macOS-specific patterns (these are specific enough to use includes)
|
||||
if (MACOS_CLOUD_STORAGE_PATTERNS.some((pattern) => resolvedPath.includes(pattern))) {
|
||||
if (MACOS_CLOUD_STORAGE_PATTERNS.some((pattern) => normalizedPath.includes(pattern))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,9 +115,15 @@ export function isCloudStoragePath(cwd: string): boolean {
|
||||
const home = os.homedir();
|
||||
for (const folder of HOME_ANCHORED_CLOUD_FOLDERS) {
|
||||
const cloudPath = path.join(home, folder);
|
||||
let normalizedCloudPath = cloudPath.split(path.sep).join('/');
|
||||
// Remove Windows drive letter if present
|
||||
normalizedCloudPath = normalizedCloudPath.replace(/^[A-Za-z]:/, '');
|
||||
// Check if resolved path starts with the cloud storage path followed by a separator
|
||||
// This ensures we match ~/Dropbox/project but not ~/Dropbox-archive or ~/my-dropbox-tool
|
||||
if (resolvedPath === cloudPath || resolvedPath.startsWith(cloudPath + path.sep)) {
|
||||
if (
|
||||
normalizedPath === normalizedCloudPath ||
|
||||
normalizedPath.startsWith(normalizedCloudPath + '/')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user