add: config error if outDir
is inside publicDir
(#8152)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
179796405e
commit
5821323285
3 changed files with 13 additions and 0 deletions
5
.changeset/brown-numbers-prove.md
Normal file
5
.changeset/brown-numbers-prove.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Displays a new config error if `outDir` is placed within `publicDir`.
|
|
@ -410,6 +410,8 @@ A future version of Astro will stop using the site pathname when producing <link
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
}).refine((obj) => !obj.outDir.toString().startsWith(obj.publicDir.toString()), {
|
||||||
|
message: '`outDir` must not be placed inside `publicDir` to prevent an infinite loop. Please adjust the directory configuration and try again'
|
||||||
});
|
});
|
||||||
|
|
||||||
return AstroConfigRelativeSchema;
|
return AstroConfigRelativeSchema;
|
||||||
|
|
|
@ -68,4 +68,10 @@ describe('Config Validation', () => {
|
||||||
).catch((err) => err);
|
).catch((err) => err);
|
||||||
expect(configError).to.be.not.instanceOf(Error);
|
expect(configError).to.be.not.instanceOf(Error);
|
||||||
});
|
});
|
||||||
|
it('Error when outDir is placed within publicDir', async () => {
|
||||||
|
const configError = await validateConfig({ outDir: './public/dist' }, process.cwd()).catch((err) => err);
|
||||||
|
expect(configError instanceof z.ZodError).to.equal(true);
|
||||||
|
expect(configError.errors[0].message).to.equal('`outDir` must not be placed inside `publicDir` to prevent an infinite loop. \
|
||||||
|
Please adjust the directory configuration and try again')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue