Skip to content

Commit

Permalink
ensure _redirects parent exists (#4676)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Apr 20, 2022
1 parent 0c3f9a0 commit e82fe2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lucky-glasses-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-netlify': patch
---

Ensure build directory exists before writing \_redirects
3 changes: 2 additions & 1 deletion packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'fs';
import { join, resolve, posix } from 'path';
import { dirname, join, resolve, posix } from 'path';
import { fileURLToPath } from 'url';
import glob from 'tiny-glob/sync.js';
import esbuild from 'esbuild';
Expand Down Expand Up @@ -234,6 +234,7 @@ function generate_lambda_functions({ builder, publish, split, esm }) {
if (existsSync('_redirects')) {
builder.copy('_redirects', redirect_file);
}
builder.mkdirp(dirname(redirect_file));
appendFileSync(redirect_file, `\n\n${redirects.join('\n')}`);
}

Expand Down

0 comments on commit e82fe2b

Please sign in to comment.