metaltest/lib/runifmain.js

15 lines
256 B
JavaScript
Raw Permalink Normal View History

2022-11-08 22:29:58 -05:00
import { fileURLToPath } from 'node:url'
const isMain = (meta) => {
const path = fileURLToPath(meta.url)
return path.includes(process.argv[1])
}
const runifmain = async (meta, fn) => {
if (isMain(meta)) {
await fn()
}
}
export { runifmain }