Run if

Run function mainFn if node only execute this
script, if function be import, don`t run

import { argv } from "node:process";

export const mainFn = () => console.log("MAIN FUNCTION RUN");

if (argv[1] === import.meta.url.slice(7)) {
  console.log('SELF RUN SCRIPT');
  mainFn();
} else {
  console.log("import test.mjs script")
}