mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 15:17:13 +00:00
19 lines
647 B
JavaScript
19 lines
647 B
JavaScript
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
export function isDirectRunPath(directPath, modulePath, platform = process.platform) {
|
|
if (!directPath || !modulePath) {
|
|
return false;
|
|
}
|
|
const pathImpl = platform === "win32" ? path.win32 : path;
|
|
const normalize =
|
|
platform === "win32"
|
|
? (value) => pathImpl.resolve(value).toLowerCase()
|
|
: (value) => pathImpl.resolve(value);
|
|
return normalize(directPath) === normalize(modulePath);
|
|
}
|
|
|
|
export function isDirectRunUrl(directPath, moduleUrl, platform = process.platform) {
|
|
return isDirectRunPath(directPath, fileURLToPath(moduleUrl), platform);
|
|
}
|