probot
Version:
A framework for building GitHub Apps to automate and improve your workflow
15 lines (14 loc) • 556 B
JavaScript
import { resolve } from "import-meta-resolve";
import { pathToFileURL } from "node:url";
export const resolveAppFunction = async (appFnId, opts = {}) => {
// These are mostly to ease testing
const basedir = process.cwd();
const resolver = opts.resolver || resolve;
const appFnPath = resolver(appFnId, pathToFileURL(basedir).href + "/");
const { default: mod } = await import(appFnPath);
// mod.default gets exported by transpiled TypeScript code
if (mod.__esModule) {
return mod.default || mod;
}
return mod;
};