-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
7fab7fd
commit 903eace
Showing
7 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
Fix build failure caused by read-only files under /public (in the presence of client-side JS). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/build-readonly-file/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/build-readonly-file", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/astro/test/fixtures/build-readonly-file/public/test.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/build-readonly-file/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
--- | ||
<script> | ||
console.log('test'); | ||
</script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.