Skip to content

Commit

Permalink
chore: apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Nov 11, 2024
1 parent f19e48b commit 5768ff4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/vercel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default function vercelAdapter({
// Secret used to verify that the caller is the astro-generated edge middleware and not a third-party
const middlewareSecret = crypto.randomUUID();

let buildOutput: 'server' | 'static';
let _buildOutput: 'server' | 'static';

let staticDir: URL | undefined;

Expand Down Expand Up @@ -226,10 +226,10 @@ export default function vercelAdapter({
),
});
},
'astro:config:done': ({ setAdapter, config, logger }) => {
buildOutput = config.output;
'astro:config:done': ({ setAdapter, config, logger, buildOutput }) => {
_buildOutput = buildOutput;

if (buildOutput === 'server') {
if (_buildOutput === 'server') {
if (maxDuration && maxDuration > 900) {
logger.warn(
`maxDuration is set to ${maxDuration} seconds, which is longer than the maximum allowed duration of 900 seconds.`
Expand All @@ -256,14 +256,14 @@ export default function vercelAdapter({
logger.warn(`Your "vercel.json" config is not a valid json file.`);
}
}
setAdapter(getAdapter({ buildOutput, edgeMiddleware, middlewareSecret, skewProtection }));
setAdapter(getAdapter({ buildOutput: _buildOutput, edgeMiddleware, middlewareSecret, skewProtection }));
} else {
setAdapter(
getAdapter({
edgeMiddleware: false,
middlewareSecret: '',
skewProtection,
buildOutput,
buildOutput: _buildOutput,
})
);
}
Expand All @@ -289,7 +289,7 @@ export default function vercelAdapter({
}
mkdirSync(new URL('./.vercel/output/static/', _config.root), { recursive: true });

if (buildOutput === 'static' && staticDir) {
if (_buildOutput === 'static' && staticDir) {
cpSync(_config.outDir, new URL('./.vercel/output/static/', _config.root), {
recursive: true,
});
Expand All @@ -309,7 +309,7 @@ export default function vercelAdapter({
middlewarePath?: string;
}> = [];

if (buildOutput === 'server') {
if (_buildOutput === 'server') {
// Merge any includes from `vite.assetsInclude
if (_config.vite.assetsInclude) {
const mergeGlobbedIncludes = (globPattern: unknown) => {
Expand Down Expand Up @@ -407,12 +407,12 @@ export default function vercelAdapter({
},
{ handle: 'filesystem' },
];
if (buildOutput === 'server') {
if (_buildOutput === 'server') {
finalRoutes.push(...routeDefinitions);
}

if (fourOhFourRoute) {
if (buildOutput === 'server') {
if (_buildOutput === 'server') {
finalRoutes.push({
src: '/.*',
dest: fourOhFourRoute.prerender
Expand Down Expand Up @@ -459,7 +459,7 @@ export default function vercelAdapter({
});

// Remove temporary folder
if (buildOutput === 'server') {
if (_buildOutput === 'server') {
await removeDir(_buildTempFolder);
}
},
Expand Down

0 comments on commit 5768ff4

Please sign in to comment.