Skip to content

Commit

Permalink
expose top level dir
Browse files Browse the repository at this point in the history
Former-commit-id: 00c222c
  • Loading branch information
Jarred-Sumner committed Sep 6, 2021
1 parent 0108695 commit d59e7b2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ type uint32 = number;
router?: Router;
reason?: FallbackStep;
problems?: Problems;
cwd?: string;
}

export interface JSX {
Expand Down
10 changes: 10 additions & 0 deletions src/api/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ function decodeFallbackMessageContainer(bb) {
result["problems"] = decodeProblems(bb);
break;

case 5:
result["cwd"] = bb.readString();
break;

default:
throw new Error("Attempted to parse invalid message");
}
Expand Down Expand Up @@ -511,6 +515,12 @@ bb.writeByte(encoded);
bb.writeByte(4);
encodeProblems(value, bb);
}

var value = message["cwd"];
if (value != null) {
bb.writeByte(5);
bb.writeString(value);
}
bb.writeByte(0);

}
Expand Down
1 change: 1 addition & 0 deletions src/api/schema.peechy
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ message FallbackMessageContainer {
Router router = 2;
FallbackStep reason = 3;
Problems problems = 4;
string cwd = 5;
}


Expand Down
10 changes: 10 additions & 0 deletions src/api/schema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ reason: ?FallbackStep = null,
/// problems
problems: ?Problems = null,

/// cwd
cwd: ?[]const u8 = null,


pub fn decode(reader: anytype) anyerror!FallbackMessageContainer {
var this = std.mem.zeroes(FallbackMessageContainer);
Expand All @@ -705,6 +708,9 @@ pub fn decode(reader: anytype) anyerror!FallbackMessageContainer {
},
4 => {
this.problems = try reader.readValue(Problems);
},
5 => {
this.cwd = try reader.readValue([]const u8);
},
else => {
return error.InvalidMessage;
Expand All @@ -731,6 +737,10 @@ if (this.problems) |problems| {
try writer.writeFieldID(4);
try writer.writeValue(problems);
}
if (this.cwd) |cwd| {
try writer.writeFieldID(5);
try writer.writeValue(cwd);
}
try writer.endMessage();
}

Expand Down
1 change: 1 addition & 0 deletions src/http.zig
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ pub const RequestContext = struct {
.message = try std.fmt.allocPrint(allocator, fmt, args),
.router = if (routes.len > 0) Api.Router{ .route = route_index, .params = params, .routes = routes } else null,
.reason = step,
.cwd = this.bundler.fs.top_level_dir,
.problems = Api.Problems{
.code = @truncate(u16, @errorToInt(err)),
.name = @errorName(err),
Expand Down

0 comments on commit d59e7b2

Please sign in to comment.