0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Restart dev server on lockfile change

This commit is contained in:
Matthew Phillips 2024-09-27 12:28:49 +01:00
parent 0a1036eef6
commit 48d3e4e957
3 changed files with 39 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Restart dev server on lockfile change

View file

@ -121,7 +121,15 @@ export async function createSettings(config: AstroConfig, cwd?: string): Promise
let watchFiles = [];
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') {

View file

@ -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 () => {
const fs = createFs(
{