-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
40 lines (33 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { adapters } from './adapters.js';
/** @type {import('.')} **/
export default function () {
return {
name: '@svelterun/adapter-auto',
async adapt(builder) {
for (const candidate of adapters) {
if (candidate.test()) {
builder.log.info(`Detected environment: ${candidate.name}. Using ${candidate.module}`);
let module;
try {
module = await import(candidate.module);
} catch (error) {
if (
error.code === 'ERR_MODULE_NOT_FOUND' &&
error.message.startsWith(`Cannot find package '${candidate.module}'`)
) {
throw new Error(
`It looks like ${candidate.module} is not installed. Please install it and try building your project again.`
);
}
throw error;
}
const adapter = module.default();
return adapter.adapt(builder);
}
}
builder.log.warn(
'Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing'
);
}
};
}