@@ -151,9 +151,23 @@ async function main() {
|
||||
process.on('SIGTERM', shutdown);
|
||||
}
|
||||
|
||||
const isEntryPoint =
|
||||
typeof process.argv[1] === 'string' &&
|
||||
import.meta.url === pathToFileURL(process.argv[1]).href;
|
||||
function isEntryModule() {
|
||||
if (typeof process.argv[1] !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const entryHref = pathToFileURL(process.argv[1]).href;
|
||||
if (typeof import.meta.url === 'string' && import.meta.url === entryHref) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
typeof __filename === 'string' &&
|
||||
pathToFileURL(__filename).href === entryHref
|
||||
);
|
||||
}
|
||||
|
||||
const isEntryPoint = isEntryModule();
|
||||
|
||||
if (isEntryPoint) {
|
||||
void main().catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user