Skip to content

Commit

Permalink
[astro add] Set output: 'server' when adding adapter (#4289)
Browse files Browse the repository at this point in the history
* fix: add `output: 'server'` when setting adapter

* chore: changeset
  • Loading branch information
bholmesdev committed Aug 12, 2022
1 parent 62763d5 commit 3ca9051
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-bears-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

[astro add] Set `output: 'server'` when adding adapter
17 changes: 17 additions & 0 deletions packages/astro/src/core/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 3ca9051

Please sign in to comment.