@fluojs/config
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAEjB,cAAc,EAKf,MAAM,YAAY,CAAC;AAqYpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CA+B/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAEvE"} | ||
| {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAEjB,cAAc,EAKf,MAAM,YAAY,CAAC;AAwZpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAgC/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAEvE"} |
+17
-0
@@ -0,1 +1,2 @@ | ||
| import { createHash } from 'node:crypto'; | ||
| import { existsSync, readFileSync, watch } from 'node:fs'; | ||
@@ -183,2 +184,12 @@ import { basename, dirname, join } from 'node:path'; | ||
| } | ||
| function hashEnvFileContent(envFile) { | ||
| try { | ||
| return createHash('sha256').update(readFileSync(envFile)).digest('hex'); | ||
| } catch (error) { | ||
| if (typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT') { | ||
| return undefined; | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
| function notifyReloadListeners(listeners, snapshot, reason) { | ||
@@ -246,3 +257,8 @@ for (const listener of listeners) { | ||
| try { | ||
| const nextEnvFileHash = hashEnvFileContent(normalized.envFile); | ||
| if (nextEnvFileHash === state.watchedEnvFileHash) { | ||
| return; | ||
| } | ||
| applyReload(normalized, state, listeners, 'watch'); | ||
| state.watchedEnvFileHash = nextEnvFileHash; | ||
| } catch (error) { | ||
@@ -289,2 +305,3 @@ notifyReloadErrorListeners(errorListeners, error, getReloadFailureReason(error) ?? 'watch'); | ||
| reloading: false, | ||
| watchedEnvFileHash: hashEnvFileContent(normalized.envFile), | ||
| watcher: undefined | ||
@@ -291,0 +308,0 @@ }; |
+1
-1
@@ -11,3 +11,3 @@ { | ||
| ], | ||
| "version": "1.0.0-beta.5", | ||
| "version": "1.0.0-beta.6", | ||
| "private": false, | ||
@@ -14,0 +14,0 @@ "license": "MIT", |
+1
-1
@@ -94,3 +94,3 @@ # @fluojs/config | ||
| Module registration과 reloader 생성은 caller-owned options를 저장하기 전에 snapshot으로 분리합니다. `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, `createConfigReloader(...)`에 넘긴 객체를 나중에 변경해도 bootstrap, manual reload, watch reload 입력은 바뀌지 않습니다. Watch mode에서 시작 시점에 env file이 없으면 빈 file snapshot처럼 취급하고 parent directory를 watch하므로, 나중에 env file을 생성해도 reload가 트리거될 수 있습니다. | ||
| Module registration과 reloader 생성은 caller-owned options를 저장하기 전에 snapshot으로 분리합니다. `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, `createConfigReloader(...)`에 넘긴 객체를 나중에 변경해도 bootstrap, manual reload, watch reload 입력은 바뀌지 않습니다. Watch mode에서 시작 시점에 env file이 없으면 빈 file snapshot처럼 취급하고 parent directory를 watch하므로, 나중에 env file을 생성해도 reload가 트리거될 수 있습니다. Watch reload는 reload 전에 최종 env file content를 마지막으로 commit된 watch baseline과 비교하므로, 내용이 바뀌지 않은 저장이나 변경 후 debounce 안에서 원래 내용으로 되돌린 burst는 인프로세스 config snapshot을 교체하지 않습니다. | ||
@@ -97,0 +97,0 @@ ## 공개 API |
+1
-1
@@ -98,3 +98,3 @@ # @fluojs/config | ||
| Module registration and reloader creation snapshot caller-owned options before storing them. Later mutations to objects passed to `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, or `createConfigReloader(...)` do not affect bootstrap, manual reloads, or watch reloads. In watch mode, a missing env file at startup is treated as an empty file snapshot while the parent directory is watched so creating the env file later can still trigger reload. | ||
| Module registration and reloader creation snapshot caller-owned options before storing them. Later mutations to objects passed to `ConfigModule.forRoot(...)`, `ConfigReloadModule.forRoot(...)`, or `createConfigReloader(...)` do not affect bootstrap, manual reloads, or watch reloads. In watch mode, a missing env file at startup is treated as an empty file snapshot while the parent directory is watched so creating the env file later can still trigger reload. Watch reloads compare the final env file content with the last committed watch baseline before reloading, so unchanged saves and change-then-revert bursts do not replace the in-process config snapshot. | ||
@@ -101,0 +101,0 @@ ## Public API |
56839
1.97%913
1.9%