Skip to content

Commit 6a09386

Browse files
committed
fix: reload server when .env files change
1 parent 08cbabe commit 6a09386

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

config/paths.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
export const ACE_FILE_NAME = 'ace'
1111
export const DEFAULT_BUILD_DIR = 'build'
1212
export const RCFILE_NAME = '.adonisrc.json'
13+
export const ENV_FILES = ['.env', '.env.testing']
1314
export const SERVER_ENTRY_FILE = 'server.ts'
1415
export const TSCONFIG_FILE_NAME = 'tsconfig.json'

npm-audit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h5 class="card-title">
5555
<div class="card">
5656
<div class="card-body">
5757
<h5 class="card-title">
58-
October 20th 2020, 8:47:38 am
58+
October 20th 2020, 8:54:39 am
5959
</h5>
6060
<p class="card-text">Last updated</p>
6161
</div>

src/DevServer/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Manifest } from '../Manifest'
1717
import { EnvParser } from '../EnvParser'
1818
import { HttpServer } from '../HttpServer'
1919

20-
import { SERVER_ENTRY_FILE } from '../../config/paths'
20+
import { ENV_FILES, SERVER_ENTRY_FILE } from '../../config/paths'
2121

2222
/**
2323
* Exposes the API to watch project for compilition changes.
@@ -284,6 +284,12 @@ export class DevServer {
284284
* New file added
285285
*/
286286
watcher.on('add', async ({ relativePath }) => {
287+
if (ENV_FILES.includes(relativePath)) {
288+
this.logger.action('create').succeeded(relativePath)
289+
this.httpServer.restart()
290+
return
291+
}
292+
287293
const metaData = this.rcFile.getMetaData(relativePath)
288294
if (!metaData.metaFile) {
289295
return
@@ -301,6 +307,12 @@ export class DevServer {
301307
* File changed
302308
*/
303309
watcher.on('change', async ({ relativePath }) => {
310+
if (ENV_FILES.includes(relativePath)) {
311+
this.logger.action('update').succeeded(relativePath)
312+
this.httpServer.restart()
313+
return
314+
}
315+
304316
const metaData = this.rcFile.getMetaData(relativePath)
305317
if (!metaData.metaFile) {
306318
return
@@ -318,6 +330,12 @@ export class DevServer {
318330
* File removed
319331
*/
320332
watcher.on('unlink', async ({ relativePath }) => {
333+
if (ENV_FILES.includes(relativePath)) {
334+
this.logger.action('delete').succeeded(relativePath)
335+
this.httpServer.restart()
336+
return
337+
}
338+
321339
const metaData = this.rcFile.getMetaData(relativePath)
322340
if (!metaData.metaFile) {
323341
return

0 commit comments

Comments
 (0)