@intellectronica/ruler 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/GitignoreUtils.js +18 -1
- package/package.json +1 -1
|
@@ -59,7 +59,24 @@ async function updateGitignore(projectRoot, paths) {
|
|
|
59
59
|
}
|
|
60
60
|
// Convert paths to relative POSIX format
|
|
61
61
|
const relativePaths = paths.map((p) => {
|
|
62
|
-
|
|
62
|
+
let relative;
|
|
63
|
+
if (path.isAbsolute(p)) {
|
|
64
|
+
relative = path.relative(projectRoot, p);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Handle relative paths that might include the project root prefix
|
|
68
|
+
const normalizedProjectRoot = path.normalize(projectRoot);
|
|
69
|
+
const normalizedPath = path.normalize(p);
|
|
70
|
+
// Get the basename of the project root to match against path prefixes
|
|
71
|
+
const projectBasename = path.basename(normalizedProjectRoot);
|
|
72
|
+
// If the path starts with the project basename, remove it
|
|
73
|
+
if (normalizedPath.startsWith(projectBasename + path.sep)) {
|
|
74
|
+
relative = normalizedPath.substring(projectBasename.length + 1);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
relative = normalizedPath;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
63
80
|
return relative.replace(/\\/g, '/'); // Convert to POSIX format
|
|
64
81
|
});
|
|
65
82
|
// Get all existing paths from .gitignore (excluding Ruler block)
|