mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -05:00
Restart dev server on lockfile change
This commit is contained in:
parent
0a1036eef6
commit
48d3e4e957
3 changed files with 39 additions and 1 deletions
5
.changeset/good-geese-run.md
Normal file
5
.changeset/good-geese-run.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Restart dev server on lockfile change
|
|
@ -121,7 +121,15 @@ export async function createSettings(config: AstroConfig, cwd?: string): Promise
|
||||||
|
|
||||||
let watchFiles = [];
|
let watchFiles = [];
|
||||||
if (cwd) {
|
if (cwd) {
|
||||||
watchFiles.push(fileURLToPath(new URL('./package.json', pathToFileURL(cwd))));
|
// We don't official support Bun, Yarn Berry, and Yarn 1 should not be used by anyone.
|
||||||
|
// Ok to add other obscure package managers.
|
||||||
|
const packageFiles = ['package.json', 'package-lock.json', 'pnpm-lock.yaml'];
|
||||||
|
|
||||||
|
for(const file of packageFiles) {
|
||||||
|
const rel = `./${file}`;
|
||||||
|
const url = new URL(rel, pathToFileURL(cwd));
|
||||||
|
watchFiles.push(fileURLToPath(url));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof tsconfig !== 'string') {
|
if (typeof tsconfig !== 'string') {
|
||||||
|
|
|
@ -171,6 +171,31 @@ describe('dev container restarts', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Is able to restart project on lockfile changes', async () => {
|
||||||
|
const fs = createFs(
|
||||||
|
{
|
||||||
|
'/src/pages/index.astro': ``,
|
||||||
|
},
|
||||||
|
root,
|
||||||
|
);
|
||||||
|
|
||||||
|
const restart = await createContainerWithAutomaticRestart({
|
||||||
|
fs,
|
||||||
|
inlineConfig: { root: fileURLToPath(root), logLevel: 'silent' },
|
||||||
|
});
|
||||||
|
await startContainer(restart.container);
|
||||||
|
assert.equal(isStarted(restart.container), true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let restartComplete = restart.restarted();
|
||||||
|
fs.writeFileSync('/pnpm-lock.yaml', `{}`);
|
||||||
|
triggerFSEvent(restart.container, fs, '/pnpm-lock.yaml', 'change');
|
||||||
|
await restartComplete;
|
||||||
|
} finally {
|
||||||
|
await restart.container.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('Is able to restart on viteServer.restart API call', async () => {
|
it('Is able to restart on viteServer.restart API call', async () => {
|
||||||
const fs = createFs(
|
const fs = createFs(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue