[astro add] Set output: 'server' when adding adapter (#4289)

* fix: add `output: 'server'` when setting adapter

* chore: changeset
This commit is contained in:
Ben Holmes 2022-08-12 12:16:19 -05:00 committed by GitHub
parent 62763d50b5
commit 3ca9051749
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
[astro add] Set `output: 'server'` when adding adapter

View file

@ -396,6 +396,23 @@ async function setAdapter(ast: t.File, adapter: IntegrationInfo, exportName: str
const configObject = path.node.declaration.arguments[0];
if (!t.isObjectExpression(configObject)) return;
let outputProp = configObject.properties.find((prop) => {
if (prop.type !== 'ObjectProperty') return false;
if (prop.key.type === 'Identifier') {
if (prop.key.name === 'output') return true;
}
if (prop.key.type === 'StringLiteral') {
if (prop.key.value === 'output') return true;
}
return false;
}) as t.ObjectProperty | undefined;
if (!outputProp) {
configObject.properties.push(
t.objectProperty(t.identifier('output'), t.stringLiteral('server'))
);
}
let adapterProp = configObject.properties.find((prop) => {
if (prop.type !== 'ObjectProperty') return false;
if (prop.key.type === 'Identifier') {