From 9f248b0563828db0e01e685aac177eaf8107906e Mon Sep 17 00:00:00 2001 From: hippotastic <6137925+hippotastic@users.noreply.github.com> Date: Mon, 11 Apr 2022 21:30:47 +0200 Subject: Make Netlify adapter actually append redirects (#3079) --- packages/integrations/netlify/src/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'packages/integrations/netlify/src') 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'); }, }, }; -- cgit v1.2.3