Skip to content

Commit 9b2802c

Browse files
authored
Restart Netlify CMS proxy server on astro.config reload (#38)
When astro.config is saved, Astro automatically reloads, which caused a second instance of netlify-cms-proxy-server to try to start and crash. This fix ensures we kill and restart the proxy server instead each time this happens.
1 parent 571ab8d commit 9b2802c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/sixty-carpets-reflect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro-netlify-cms": patch
3+
---
4+
5+
Restart Netlify CMS proxy server when astro.config reloads

integration/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export default function NetlifyCMS({
3535
adminPath = adminPath.slice(0, -1);
3636
}
3737

38+
let proxy: ReturnType<typeof spawn>;
39+
3840
const NetlifyCMSIntegration: AstroIntegration = {
3941
name: 'netlify-cms',
4042
hooks: {
@@ -73,13 +75,17 @@ export default function NetlifyCMS({
7375
},
7476

7577
'astro:server:start': () => {
76-
const proxy = spawn('netlify-cms-proxy-server', {
78+
proxy = spawn('netlify-cms-proxy-server', {
7779
stdio: 'inherit',
7880
// Run in shell on Windows to make sure the npm package can be found.
7981
shell: process.platform === 'win32',
8082
});
8183
process.on('exit', () => proxy.kill());
8284
},
85+
86+
'astro:server:done': () => {
87+
proxy.kill();
88+
},
8389
},
8490
};
8591
return [react(), NetlifyCMSIntegration];

0 commit comments

Comments
 (0)