Skip to content

Commit 4063bf6

Browse files
B4nanclaude
andcommitted
fix: remove unused fs-extra dep, dedupe zod, preserve empty-string env var coercion
Empty-string env vars now reach the schema coercion layer (matching v3 behavior where '' produced false for booleans and 0 for numbers). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 326a4ba commit 4063bf6

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"@sapphire/async-queue": "^1.5.5",
6060
"@vladfrangu/async_event_emitter": "^2.4.6",
6161
"csv-stringify": "^6.5.2",
62-
"fs-extra": "^11.3.0",
6362
"json5": "^2.2.3",
6463
"minimatch": "^10.0.1",
6564
"ow": "^2.0.0",

packages/core/src/configuration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,16 @@ export class Configuration {
264264
}
265265

266266
/**
267-
* Reads the first non-empty env var value for a field definition.
267+
* Reads the first defined env var value for a field definition.
268+
* Empty strings are passed through — schema coercion handles them
269+
* (e.g. `coerceBoolean` treats `''` as `false`).
268270
*/
269271
private static readEnvVar(fieldDef: ConfigField): string | undefined {
270272
if (!fieldDef.envVar) return undefined;
271273
const envVars = Array.isArray(fieldDef.envVar) ? fieldDef.envVar : [fieldDef.envVar];
272274
for (const envVar of envVars) {
273275
const value = process.env[envVar];
274-
if (value != null && value !== '') return value;
276+
if (value != null) return value;
275277
}
276278
return undefined;
277279
}

packages/core/test/core/configuration.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ describe('Configuration', () => {
106106
expect(new Configuration().headless).toBe(true);
107107
});
108108

109+
it('treats empty-string boolean env var as false', () => {
110+
setEnv('CRAWLEE_HEADLESS', '');
111+
expect(new Configuration().headless).toBe(false);
112+
113+
setEnv('CRAWLEE_PURGE_ON_START', '');
114+
expect(new Configuration().purgeOnStart).toBe(false);
115+
});
116+
117+
it('coerces empty-string number env var to 0', () => {
118+
setEnv('CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS', '');
119+
expect(new Configuration().persistStateIntervalMillis).toBe(0);
120+
121+
setEnv('CRAWLEE_MEMORY_MBYTES', '');
122+
expect(new Configuration().memoryMbytes).toBe(0);
123+
});
124+
109125
it('coerces number env vars', () => {
110126
setEnv('CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS', '30000');
111127
expect(new Configuration().persistStateIntervalMillis).toBe(30_000);

yarn.lock

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,6 @@ __metadata:
961961
"@sapphire/async-queue": "npm:^1.5.5"
962962
"@vladfrangu/async_event_emitter": "npm:^2.4.6"
963963
csv-stringify: "npm:^6.5.2"
964-
fs-extra: "npm:^11.3.0"
965964
json5: "npm:^2.2.3"
966965
minimatch: "npm:^10.0.1"
967966
ow: "npm:^2.0.0"
@@ -15922,16 +15921,9 @@ __metadata:
1592215921
languageName: node
1592315922
linkType: hard
1592415923

15925-
"zod@npm:^3.24.0 || ^4.0.0":
15924+
"zod@npm:^3.24.0 || ^4.0.0, zod@npm:^3.25 || ^4.0, zod@npm:^4.3.5":
1592615925
version: 4.3.6
1592715926
resolution: "zod@npm:4.3.6"
1592815927
checksum: 10c0/860d25a81ab41d33aa25f8d0d07b091a04acb426e605f396227a796e9e800c44723ed96d0f53a512b57be3d1520f45bf69c0cb3b378a232a00787a2609625307
1592915928
languageName: node
1593015929
linkType: hard
15931-
15932-
"zod@npm:^3.25 || ^4.0, zod@npm:^4.3.5":
15933-
version: 4.3.5
15934-
resolution: "zod@npm:4.3.5"
15935-
checksum: 10c0/5a2db7e59177a3d7e202543f5136cb87b97b047b77c8a3d824098d3fa8b80d3aa40a0a5f296965c3b82dfdccdd05dbbfacce91347f16a39c675680fd7b1ab109
15936-
languageName: node
15937-
linkType: hard

0 commit comments

Comments
 (0)