async function get_adapter() {
	const match = adapters.find((candidate) => candidate.test());

	if (!match) return;

	/** @type {string} */
	let resolved;

	try {
		resolved = resolve_peer(match.module);
	} catch {
		const package_manager = detect_package_manager();
		const command = commands[package_manager](match.module, match.version);

		try {
			console.log(`Installing ${match.module}...`);

			execSync(command, {
				stdio: 'inherit',
				env: {
					...process.env,
					NODE_ENV: undefined
				}
			});

			resolved = resolve_peer(match.module);

			console.log(`Successfully installed ${match.module}.`);
			console.warn(
				`\nIf you plan on staying on this deployment platform, consider replacing @sveltejs/adapter-auto with ${match.module}. This will give you faster and more robust installs, and more control over deployment configuration.\n`
			);
		} catch (e) {
			throw new Error(
				`Could not install ${match.module}. Please install it yourself by adding it to your package.json's devDependencies and try building your project again.`,
				{ cause: e }
			);
		}
	}

	/** @type {{ default: () => Adapter }} */
	const module = await import(resolved);

	const adapter = module.default();

	return {
		...adapter,
		adapt: (builder) => {
			builder.log.info(`Detected environment: ${match.name}. Using ${match.module}`);
			return adapter.adapt(builder);
		}
	};
}
@returns {Promise<Adapter | undefined>} The corresponding adapter for the current environment if found otherwise undefined