15 lines
256 B
JavaScript
15 lines
256 B
JavaScript
|
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 }
|