function main()

in src/kinds/nodejs/mount-require.js [40:65]


function main(args) { // lgtm [js/unused-local-variable]
    process.chdir(nodePath.dirname(path));

    if (firstRun) {
        const start = Date.now();
        console.log(`[wskdebug] loading action sources from ${sourceFile}`);
        // validation with better error messages
        try {
            require(path);
        } catch (e) {
            throw `Cannot load module '${sourceFile}': ${e}`;
        }

        if (typeof require(path)[mainFn] !== "function") {
            throw `'${mainFn}' is not a function in '${sourceFile}'. Specify the right function in wskdebug using --main.`;
        }
        firstRun = false;
        console.log(`[wskdebug] loaded in ${Date.now() - start} ms.`);
    }

    // force reload of entire mounted action on every invocation
    clearEntireRequireCache();

    // require and invoke main function
    return require(path)[mainFn](args);
}