Merge pull request #1549 from MoerAI/fix/windows-path-absolute-check
fix(hooks): use path.isAbsolute() for cross-platform path detection on Windows
This commit is contained in:
commit
305d036577
@ -1,11 +1,11 @@
|
|||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
import { dirname, join, resolve } from "node:path";
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
||||||
|
|
||||||
import { AGENTS_FILENAME } from "./constants";
|
import { AGENTS_FILENAME } from "./constants";
|
||||||
|
|
||||||
export function resolveFilePath(rootDirectory: string, path: string): string | null {
|
export function resolveFilePath(rootDirectory: string, path: string): string | null {
|
||||||
if (!path) return null;
|
if (!path) return null;
|
||||||
if (path.startsWith("/")) return path;
|
if (isAbsolute(path)) return path;
|
||||||
return resolve(rootDirectory, path);
|
return resolve(rootDirectory, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
import { dirname, join, resolve } from "node:path";
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
||||||
|
|
||||||
import { README_FILENAME } from "./constants";
|
import { README_FILENAME } from "./constants";
|
||||||
|
|
||||||
export function resolveFilePath(rootDirectory: string, path: string): string | null {
|
export function resolveFilePath(rootDirectory: string, path: string): string | null {
|
||||||
if (!path) return null;
|
if (!path) return null;
|
||||||
if (path.startsWith("/")) return path;
|
if (isAbsolute(path)) return path;
|
||||||
return resolve(rootDirectory, path);
|
return resolve(rootDirectory, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user