← Files Flows by plugin.spaceARCHIVED FILE

lib/entrypoint.mjs

443 Bytes · Nov 30, 2026 · 00:17 UTC

↓ Download file

import { realpathSync } from 'node:fs';
import { fileURLToPath } from 'node:url';

// Node resolves module URLs through symlinks, while argv can retain the alias
// (for example /var -> /private/var on macOS, or an installed plugin link).
export function isEntrypoint(moduleUrl, entry = process.argv[1]) {
  if (!entry) return false;
  try { return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(entry); }
  catch { return false; }
}

SHA-256: 008419577211bca064adbb4ac17ae6cd5ff0af990e81a981c6cfd78694d213ea