Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and github-actions[bot] committed May 11, 2022
1 parent efe4f1a commit 3bb07a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/integrations/netlify/src/integration-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
buildConfig.server = new URL('./functions/', _config.outDir);
},
'astro:build:done': async ({ routes, dir }) => {
await createRedirects(routes, dir, entryFile, false);
await createRedirects(routes, dir, entryFile, false);
},
},
};
Expand Down
46 changes: 23 additions & 23 deletions packages/integrations/netlify/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import type { RouteData } from 'astro';
import fs from 'fs';

export async function createRedirects(
routes: RouteData[],
dir: URL,
entryFile: string,
edge: boolean
) {
const _redirectsURL = new URL('./_redirects', dir);
const kind = edge ? 'edge-functions' : 'functions'
routes: RouteData[],
dir: URL,
entryFile: string,
edge: boolean
) {
const _redirectsURL = new URL('./_redirects', dir);
const kind = edge ? 'edge-functions' : 'functions';

// Create the redirects file that is used for routing.
let _redirects = '';
for (const route of routes) {
if (route.pathname) {
_redirects += `
// Create the redirects file that is used for routing.
let _redirects = '';
for (const route of routes) {
if (route.pathname) {
_redirects += `
${route.pathname} /.netlify/${kind}/${entryFile} 200`;
} else {
const pattern =
'/' + route.segments.map(([part]) => (part.dynamic ? '*' : part.content)).join('/');
_redirects += `
} else {
const pattern =
'/' + route.segments.map(([part]) => (part.dynamic ? '*' : part.content)).join('/');
_redirects += `
${pattern} /.netlify/${kind}/${entryFile} 200`;
}
}
}
}

// 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');
}
// 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');
}

0 comments on commit 3bb07a0

Please sign in to comment.