summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/src
diff options
context:
space:
mode:
authorGravatar hippotastic <6137925+hippotastic@users.noreply.github.com> 2022-04-11 21:30:47 +0200
committerGravatar GitHub <noreply@github.com> 2022-04-11 12:30:47 -0700
commit9f248b0563828db0e01e685aac177eaf8107906e (patch)
tree4ad148a351f4e6392c1b7119a8b225303af1aecc /packages/integrations/netlify/src
parent771127ea294fb297c080b2bb3e74b433043b90f4 (diff)
downloadastro-9f248b0563828db0e01e685aac177eaf8107906e.tar.gz
astro-9f248b0563828db0e01e685aac177eaf8107906e.tar.zst
astro-9f248b0563828db0e01e685aac177eaf8107906e.zip
Make Netlify adapter actually append redirects (#3079)
Diffstat (limited to 'packages/integrations/netlify/src')
-rw-r--r--packages/integrations/netlify/src/index.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts
index 60aad4b79..c473de67a 100644
--- a/packages/integrations/netlify/src/index.ts
+++ b/packages/integrations/netlify/src/index.ts
@@ -53,11 +53,10 @@ ${pattern} /.netlify/functions/${entryFile} 200`;
}
}
- if (fs.existsSync(_redirects)) {
- await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
- } else {
- await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8');
- }
+ // Always use appendFile() because the redirects file could already exist,
+ // e.g. due to a `/public/_redirects` file that got copied to the output dir.
+ // If the file does not exist yet, appendFile() automatically creates it.
+ await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8');
},
},
};