diff options
author | 2021-09-07 03:21:58 -0700 | |
---|---|---|
committer | 2021-09-07 03:21:58 -0700 | |
commit | 1d1a70c21fc1f6e9e618cb52262e21bc37ac4be3 (patch) | |
tree | c942103d08048141f417a4b75130326b53b73cb9 /src/runtime.zig | |
parent | d59e7b27b0b525126fe5011f5ab393f9f5e6659a (diff) | |
download | bun-1d1a70c21fc1f6e9e618cb52262e21bc37ac4be3.tar.gz bun-1d1a70c21fc1f6e9e618cb52262e21bc37ac4be3.tar.zst bun-1d1a70c21fc1f6e9e618cb52262e21bc37ac4be3.zip |
WIP error css
Former-commit-id: 36f03bf491cf274f68361e334a706538464ee271
Diffstat (limited to 'src/runtime.zig')
-rw-r--r-- | src/runtime.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/runtime.zig b/src/runtime.zig index c426ccb07..32c5f752e 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -8,6 +8,33 @@ const Schema = @import("./api/schema.zig"); const Api = Schema.Api; +const ErrorCSSPath = "../examples/hello-next/bun-framework-next/bun-error.css"; + +pub const ErrorCSS = struct { + pub const ProdSourceContent = @embedFile(ErrorCSSPath); + + pub fn sourceContent() string { + if (comptime isDebug) { + var dirpath = std.fs.path.dirname(@src().file).?; + var env = std.process.getEnvMap(default_allocator) catch unreachable; + + const dir = std.mem.replaceOwned( + u8, + default_allocator, + dirpath, + "jarred", + env.get("USER").?, + ) catch unreachable; + var runtime_path = std.fs.path.join(default_allocator, &[_]string{ dir, ErrorCSSPath }) catch unreachable; + const file = std.fs.openFileAbsolute(runtime_path, .{}) catch unreachable; + defer file.close(); + return file.readToEndAlloc(default_allocator, (file.stat() catch unreachable).size) catch unreachable; + } else { + return ProdSourceContent; + } + } +}; + pub const Fallback = struct { pub const ProdSourceContent = @embedFile("./fallback.out.js"); pub const HTMLTemplate = @embedFile("./fallback.html"); |