diff options
author | 2023-08-28 04:39:16 -0700 | |
---|---|---|
committer | 2023-08-28 04:39:16 -0700 | |
commit | e2a17344dc543c9c652cfe2b14cd2709dd6cfd22 (patch) | |
tree | fe93965d39886494aee12dca71bdcf2a991d806f /src/cli.zig | |
parent | efe987e8d12e824dde840b56cbb704feabe26ed1 (diff) | |
download | bun-e2a17344dc543c9c652cfe2b14cd2709dd6cfd22.tar.gz bun-e2a17344dc543c9c652cfe2b14cd2709dd6cfd22.tar.zst bun-e2a17344dc543c9c652cfe2b14cd2709dd6cfd22.zip |
just kernel32 things (#4354)
* just kernel32 things
* more
* Update linux_c.zig
* Update windows_c.zig
* Add workaround
Workaround https://github.com/ziglang/zig/issues/16980
* Rename http.zig to bun_dev_http_server.zig
* Rename usages
* more
* more
* more
* thanks tigerbeetle
* Rename `JSC.Node.Syscall` -> `bun.sys`
* more
* woops
* more!
* hmm
* it says there are only 37 errors, but that's not true
* populate argv
* it says 32 errors!
* 24 errors
* fix regular build
* 12 left!
* Still 12 left!
* more
* 2 errors left...
* 1 more error
* Add link to Tigerbeetle
* Fix the remainign error
* Fix test timeout
* Update syscall.zig
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/cli.zig')
-rw-r--r-- | src/cli.zig | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cli.zig b/src/cli.zig index 156f9e48d..68ae7e4c2 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -114,8 +114,8 @@ pub const Arguments = struct { defer allocator.free(outpath); var file = try std.fs.openFileAbsolute(outpath, std.fs.File.OpenFlags{ .mode = .read_only }); defer file.close(); - const stats = try file.stat(); - return try file.readToEndAlloc(allocator, stats.size); + const size = try file.getEndPos(); + return try file.readToEndAlloc(allocator, size); } pub fn resolve_jsx_runtime(str: string) !Api.JsxRuntime { @@ -1076,7 +1076,7 @@ pub const Command = struct { }; pub fn which() Tag { - var args_iter = ArgsIterator{ .buf = std.os.argv }; + var args_iter = ArgsIterator{ .buf = bun.argv() }; // first one is the executable name const argv0 = args_iter.next() orelse return .HelpCommand; @@ -1130,7 +1130,10 @@ pub const Command = struct { RootCommandMatcher.case("r"), RootCommandMatcher.case("remove"), RootCommandMatcher.case("rm"), RootCommandMatcher.case("uninstall") => .RemoveCommand, RootCommandMatcher.case("run") => .RunCommand, - RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => .DevCommand, + RootCommandMatcher.case("d"), RootCommandMatcher.case("dev") => if (comptime Environment.isWindows) { + Output.prettyErrorln("<r><red>error:<r> bun dev is not supported on Windows.", .{}); + Global.exit(1); + } else .DevCommand, RootCommandMatcher.case("help") => .HelpCommand, else => .AutoCommand, @@ -1210,9 +1213,9 @@ pub const Command = struct { }; ctx.args.target = Api.Target.bun; - var argv = try bun.default_allocator.alloc(string, std.os.argv.len -| 1); - if (std.os.argv.len > 1) { - for (argv, std.os.argv[1..]) |*dest, src| { + var argv = try bun.default_allocator.alloc(string, bun.argv().len -| 1); + if (bun.argv().len > 1) { + for (argv, bun.argv()[1..]) |*dest, src| { dest.* = bun.span(src); } } @@ -1231,7 +1234,7 @@ pub const Command = struct { switch (tag) { .DiscordCommand => return try DiscordCommand.exec(allocator), .HelpCommand => return try HelpCommand.exec(allocator), - .InitCommand => return try InitCommand.exec(allocator, std.os.argv), + .InitCommand => return try InitCommand.exec(allocator, bun.argv()), else => {}, } @@ -1243,6 +1246,7 @@ pub const Command = struct { try BuildCommand.exec(ctx); }, .DevCommand => { + if (comptime Environment.isWindows) unreachable; if (comptime bun.fast_debug_build_mode and bun.fast_debug_build_cmd != .DevCommand) unreachable; const ctx = try Command.Context.create(allocator, log, .DevCommand); @@ -1465,7 +1469,7 @@ pub const Command = struct { // KEYWORDS: open file argv argv0 if (ctx.args.entry_points.len == 1) { if (strings.eqlComptime(extension, ".lockb")) { - for (std.os.argv) |arg| { + for (bun.argv()) |arg| { if (strings.eqlComptime(std.mem.span(arg), "--hash")) { try PackageManagerCommand.printHash(ctx, ctx.args.entry_points[0]); return; |