18 lines
405 B
JavaScript
18 lines
405 B
JavaScript
import { fileURLToPath } from 'node:url'
|
|
|
|
const isMain = (meta) => {
|
|
const path = fileURLToPath(meta.url)
|
|
|
|
return path.includes(process.argv[1])
|
|
}
|
|
|
|
import { errorreporter, summaryreporter } from '../index.js'
|
|
const runifmain = async (meta, fn, ...args) => {
|
|
if (!isMain(meta)) return
|
|
|
|
if (args.length == 0) args.push(summaryreporter(), errorreporter())
|
|
await fn(...args)
|
|
}
|
|
|
|
export { runifmain }
|