aboutsummaryrefslogtreecommitdiff
path: root/src/bunfig.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/bunfig.zig')
-rw-r--r--src/bunfig.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bunfig.zig b/src/bunfig.zig
index 4a341ef20..c6ecb7c10 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -169,6 +169,22 @@ pub const Bunfig = struct {
}
}
}
+
+ if (json.get("preload")) |expr| {
+ if (expr.asArray()) |array_| {
+ var array = array_;
+ var preloads = try std.ArrayList(string).initCapacity(allocator, array.array.items.len);
+ errdefer preloads.deinit();
+ while (array.next()) |item| {
+ try this.expect(item, .e_string);
+ if (item.data.e_string.len() > 0)
+ preloads.appendAssumeCapacity(try item.data.e_string.string(allocator));
+ }
+ this.ctx.preloads = preloads.items;
+ } else if (expr.data != .e_null) {
+ try this.addError(expr.loc, "Expected preload to be an array");
+ }
+ }
}
if (comptime cmd == .DevCommand or cmd == .AutoCommand) {
@@ -196,6 +212,22 @@ pub const Bunfig = struct {
if (test_.get("root")) |root| {
this.ctx.debug.test_directory = root.asString(this.allocator) orelse "";
}
+
+ if (test_.get("preload")) |expr| {
+ if (expr.asArray()) |array_| {
+ var array = array_;
+ var preloads = try std.ArrayList(string).initCapacity(allocator, array.array.items.len);
+ errdefer preloads.deinit();
+ while (array.next()) |item| {
+ try this.expect(item, .e_string);
+ if (item.data.e_string.len() > 0)
+ preloads.appendAssumeCapacity(try item.data.e_string.string(allocator));
+ }
+ this.ctx.preloads = preloads.items;
+ } else if (expr.data != .e_null) {
+ try this.addError(expr.loc, "Expected preload to be an array");
+ }
+ }
}
}