import { types as t, NodePath } from '@babel/core'; export const getProgramPath = ( path: NodePath | NodePath, ): NodePath | undefined => { if (t.isProgram(path)) return path as NodePath; if (path.parentPath) { return getProgramPath(path.parentPath); } return undefined; };