From 56ac230e5e6c849376a72e12f9e65ea3800fe18e Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Tue, 3 Feb 2026 17:36:03 -0800 Subject: [PATCH] add ability for consumers to specify env file / log info & continue if not exists --- lambdabuild.zig | 6 +++++- tools/build/src/deploy.zig | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lambdabuild.zig b/lambdabuild.zig index 9aecd27..053a85c 100644 --- a/lambdabuild.zig +++ b/lambdabuild.zig @@ -16,6 +16,10 @@ pub const Config = struct { /// Default IAM role name if not specified via -Drole-name. default_role_name: []const u8 = "lambda_basic_execution", + + /// Default environment file if not specified via -Denv-file. + /// If the file doesn't exist, it's silently skipped. + default_env_file: ?[]const u8 = ".env", }; /// Information about the configured Lambda build steps. @@ -84,7 +88,7 @@ pub fn configureBuild( []const u8, "env-file", "Path to environment variables file (KEY=VALUE format)", - ) orelse null; + ) orelse config.default_env_file; const allow_principal = b.option( []const u8, "allow-principal", diff --git a/tools/build/src/deploy.zig b/tools/build/src/deploy.zig index cb83ccc..7bbd8d1 100644 --- a/tools/build/src/deploy.zig +++ b/tools/build/src/deploy.zig @@ -138,8 +138,12 @@ fn loadEnvFile( allocator: std.mem.Allocator, ) !void { const file = std.fs.cwd().openFile(path, .{}) catch |err| { + if (err == error.FileNotFound) { + std.log.info("Env file '{s}' not found, skipping", .{path}); + return; + } std.log.err("Failed to open env file '{s}': {}", .{ path, err }); - return error.EnvFileNotFound; + return error.EnvFileOpenError; }; defer file.close();