MCPcopy
hub / github.com/google/zx / isMain

Function isMain

src/cli.ts:262–273  ·  view source on GitHub ↗
(
  metaurl: string = import.meta.url,
  scriptpath: string = process.argv[1]
)

Source from the content-addressed store, hash-verified

260}
261
262export function isMain(
263 metaurl: string = import.meta.url,
264 scriptpath: string = process.argv[1]
265): boolean {
266 if (metaurl.startsWith('file:')) {
267 const modulePath = url.fileURLToPath(metaurl).replace(/\.\w+$/, '')
268 const mainPath = fs.realpathSync(scriptpath).replace(/\.\w+$/, '')
269 return mainPath === modulePath
270 }
271
272 return false
273}
274
275export function normalizeExt(ext?: string): string | undefined {
276 return ext ? path.parse(`foo.${ext}`).ext : ext

Callers 2

cli.test.jsFile · 0.85
cli.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…