mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(core): build failure caused by read-only files (#10195)
* fix(core): build failure caused by read-only files * test: fix fixtures/build-readonly-file * other: format code
This commit is contained in:
parent
7fab7fd8c6
commit
903eace233
7 changed files with 77 additions and 0 deletions
5
.changeset/nervous-flowers-tell.md
Normal file
5
.changeset/nervous-flowers-tell.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fix build failure caused by read-only files under /public (in the presence of client-side JS).
|
|
@ -309,6 +309,7 @@ async function clientBuild(
|
|||
...viteConfig.build,
|
||||
emptyOutDir: false,
|
||||
outDir: fileURLToPath(out),
|
||||
copyPublicDir: ssr,
|
||||
rollupOptions: {
|
||||
...viteConfig.build?.rollupOptions,
|
||||
input: Array.from(input),
|
||||
|
|
51
packages/astro/test/build-readonly-file.test.js
Normal file
51
packages/astro/test/build-readonly-file.test.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { after, before, describe, it } from 'node:test';
|
||||
import { fileURLToPath } from 'url';
|
||||
import testAdapter from './test-adapter.js';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('When a read-only file exists in /public (static)', () => {
|
||||
let fixture;
|
||||
let testFilePath;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/build-readonly-file/',
|
||||
});
|
||||
|
||||
testFilePath = fileURLToPath(fixture.config.publicDir) + 'test.txt';
|
||||
fs.chmodSync(testFilePath, 0o444);
|
||||
});
|
||||
|
||||
it('Gets successfully build', async () => {
|
||||
await fixture.build();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
fs.chmodSync(testFilePath, 0o666);
|
||||
fixture.clean();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When a read-only file exists in /public (server)', () => {
|
||||
let fixture;
|
||||
let testFilePath;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/build-readonly-file/',
|
||||
adapter: testAdapter(),
|
||||
});
|
||||
|
||||
testFilePath = fileURLToPath(fixture.config.publicDir) + 'test.txt';
|
||||
fs.chmodSync(testFilePath, 0o444);
|
||||
});
|
||||
|
||||
it('Gets successfully build', async () => {
|
||||
await fixture.build();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
fs.chmodSync(testFilePath, 0o666);
|
||||
fixture.clean();
|
||||
});
|
||||
});
|
8
packages/astro/test/fixtures/build-readonly-file/package.json
vendored
Normal file
8
packages/astro/test/fixtures/build-readonly-file/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@test/build-readonly-file",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
1
packages/astro/test/fixtures/build-readonly-file/public/test.txt
vendored
Normal file
1
packages/astro/test/fixtures/build-readonly-file/public/test.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test
|
5
packages/astro/test/fixtures/build-readonly-file/src/pages/index.astro
vendored
Normal file
5
packages/astro/test/fixtures/build-readonly-file/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
---
|
||||
<script>
|
||||
console.log('test');
|
||||
</script>
|
|
@ -2327,6 +2327,12 @@ importers:
|
|||
specifier: ^10.19.2
|
||||
version: 10.19.3
|
||||
|
||||
packages/astro/test/fixtures/build-readonly-file:
|
||||
dependencies:
|
||||
astro:
|
||||
specifier: workspace:*
|
||||
version: link:../../..
|
||||
|
||||
packages/astro/test/fixtures/client-address:
|
||||
dependencies:
|
||||
astro:
|
||||
|
|
Loading…
Reference in a new issue