aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/add_completions.zig2
-rw-r--r--src/cli/build_command.zig34
-rw-r--r--src/cli/bunx_command.zig4
-rw-r--r--src/cli/create_command.zig26
-rw-r--r--src/cli/package_manager_command.zig2
-rw-r--r--src/cli/run_command.zig8
-rw-r--r--src/cli/test_command.zig2
-rw-r--r--src/cli/upgrade_command.zig14
8 files changed, 46 insertions, 46 deletions
diff --git a/src/cli/add_completions.zig b/src/cli/add_completions.zig
index 2e7d6b4ea..1267ea159 100644
--- a/src/cli/add_completions.zig
+++ b/src/cli/add_completions.zig
@@ -66,7 +66,7 @@ pub const index: Index = if (Environment.isDebug) Index.initFill(&.{"OOMWorkArou
break;
}
}
- array.set(@enumFromInt(FirstLetter, i), &record);
+ array.set(@as(FirstLetter, @enumFromInt(i)), &record);
@setEvalBranchQuota(999999);
i = next_i;
diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig
index ef99f7765..bb4eb4313 100644
--- a/src/cli/build_command.zig
+++ b/src/cli/build_command.zig
@@ -345,7 +345,7 @@ pub const BuildCommand = struct {
this_bundler.options.public_path,
outfile,
);
- const compiled_elapsed = @divTrunc(@truncate(i64, std.time.nanoTimestamp() - bundled_end), @as(i64, std.time.ns_per_ms));
+ const compiled_elapsed = @divTrunc(@as(i64, @truncate(std.time.nanoTimestamp() - bundled_end)), @as(i64, std.time.ns_per_ms));
const compiled_elapsed_digit_count: isize = switch (compiled_elapsed) {
0...9 => 3,
10...99 => 2,
@@ -355,9 +355,9 @@ pub const BuildCommand = struct {
};
const padding_buf = [_]u8{' '} ** 16;
- Output.pretty("{s}", .{padding_buf[0..@intCast(usize, compiled_elapsed_digit_count)]});
+ Output.pretty("{s}", .{padding_buf[0..@as(usize, @intCast(compiled_elapsed_digit_count))]});
- Output.printElapsedStdoutTrim(@floatFromInt(f64, compiled_elapsed));
+ Output.printElapsedStdoutTrim(@as(f64, @floatFromInt(compiled_elapsed)));
Output.prettyln(" <green>compile<r> <b><blue>{s}<r>", .{
outfile,
@@ -407,14 +407,14 @@ pub const BuildCommand = struct {
.buffer = .{
.ptr = @constCast(value.bytes.ptr),
// TODO: handle > 4 GB files
- .len = @truncate(u32, value.bytes.len),
- .byte_len = @truncate(u32, value.bytes.len),
+ .len = @as(u32, @truncate(value.bytes.len)),
+ .byte_len = @as(u32, @truncate(value.bytes.len)),
},
},
},
.encoding = .buffer,
.mode = if (f.is_executable) 0o755 else 0o644,
- .dirfd = @intCast(bun.FileDescriptor, root_dir.dir.fd),
+ .dirfd = @as(bun.FileDescriptor, @intCast(root_dir.dir.fd)),
.file = .{
.path = JSC.Node.PathLike{
.string = JSC.PathString.init(rel_path),
@@ -451,7 +451,7 @@ pub const BuildCommand = struct {
try writer.writeByteNTimes(' ', 2);
try writer.writeAll(rel_path);
try writer.writeByteNTimes(' ', padding_count);
- const size = @floatFromInt(f64, f.size) / 1000.0;
+ const size = @as(f64, @floatFromInt(f.size)) / 1000.0;
try std.fmt.formatFloatDecimal(size, .{ .precision = 2 }, writer);
try writer.writeAll(" KB\n");
}
@@ -461,7 +461,7 @@ pub const BuildCommand = struct {
if (write_summary and log.errors == 0) {
Output.prettyln("\n", .{});
Output.printElapsedStdoutTrim(
- @floatFromInt(f64, (@divTrunc(@truncate(i64, std.time.nanoTimestamp() - bun.CLI.start_time), @as(i64, std.time.ns_per_ms)))),
+ @as(f64, @floatFromInt((@divTrunc(@as(i64, @truncate(std.time.nanoTimestamp() - bun.CLI.start_time)), @as(i64, std.time.ns_per_ms))))),
);
if (this_bundler.options.transform_only) {
Output.prettyln(" <green>transpile<r>", .{});
@@ -490,10 +490,10 @@ fn exitOrWatch(code: u8, watch: bool) void {
fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_code_length: usize, reachable_file_count: usize, output_files: []const options.OutputFile) void {
const padding_buf = [_]u8{' '} ** 16;
- const bundle_until_now = @divTrunc(@truncate(i64, bundled_end - bun.CLI.start_time), @as(i64, std.time.ns_per_ms));
+ const bundle_until_now = @divTrunc(@as(i64, @truncate(bundled_end - bun.CLI.start_time)), @as(i64, std.time.ns_per_ms));
const bundle_elapsed = if (minified)
- bundle_until_now - @intCast(i64, @truncate(u63, minify_duration))
+ bundle_until_now - @as(i64, @intCast(@as(u63, @truncate(minify_duration))))
else
bundle_until_now;
@@ -505,8 +505,8 @@ fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_c
else => 0,
};
if (minified) {
- Output.pretty("{s}", .{padding_buf[0..@intCast(usize, minified_digit_count)]});
- Output.printElapsedStdoutTrim(@floatFromInt(f64, minify_duration));
+ Output.pretty("{s}", .{padding_buf[0..@as(usize, @intCast(minified_digit_count))]});
+ Output.printElapsedStdoutTrim(@as(f64, @floatFromInt(minify_duration)));
const output_size = brk: {
var total_size: u64 = 0;
for (output_files) |f| {
@@ -519,19 +519,19 @@ fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_c
};
// this isn't an exact size
// we may inject sourcemaps or comments or import paths
- const delta: i64 = @truncate(i64, @intCast(i65, input_code_length) - @intCast(i65, output_size));
+ const delta: i64 = @as(i64, @truncate(@as(i65, @intCast(input_code_length)) - @as(i65, @intCast(output_size))));
if (delta > 1024) {
Output.prettyln(
" <green>minify<r> -{} <d>(estimate)<r>",
.{
- bun.fmt.size(@intCast(usize, delta)),
+ bun.fmt.size(@as(usize, @intCast(delta))),
},
);
} else if (-delta > 1024) {
Output.prettyln(
" <b>minify<r> +{} <d>(estimate)<r>",
.{
- bun.fmt.size(@intCast(usize, -delta)),
+ bun.fmt.size(@as(usize, @intCast(-delta))),
},
);
} else {
@@ -547,8 +547,8 @@ fn printSummary(bundled_end: i128, minify_duration: u64, minified: bool, input_c
else => 0,
};
- Output.pretty("{s}", .{padding_buf[0..@intCast(usize, bundle_elapsed_digit_count)]});
- Output.printElapsedStdoutTrim(@floatFromInt(f64, bundle_elapsed));
+ Output.pretty("{s}", .{padding_buf[0..@as(usize, @intCast(bundle_elapsed_digit_count))]});
+ Output.printElapsedStdoutTrim(@as(f64, @floatFromInt(bundle_elapsed)));
Output.prettyln(
" <green>bundle<r> {d} modules",
.{
diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig
index 365f2c9ed..84c7e1bba 100644
--- a/src/cli/bunx_command.zig
+++ b/src/cli/bunx_command.zig
@@ -365,10 +365,10 @@ pub const BunxCommand = struct {
}
},
.Signal => |signal| {
- Global.exit(@truncate(u7, signal));
+ Global.exit(@as(u7, @truncate(signal)));
},
.Stopped => |signal| {
- Global.exit(@truncate(u7, signal));
+ Global.exit(@as(u7, @truncate(signal)));
},
// shouldn't happen
else => {
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig
index d536c4750..aff34e9b4 100644
--- a/src/cli/create_command.zig
+++ b/src/cli/create_command.zig
@@ -104,7 +104,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string,
count += 1;
}
- const npm_args = 2 * @intCast(usize, @intFromBool(npm_client != null));
+ const npm_args = 2 * @as(usize, @intCast(@intFromBool(npm_client != null)));
const total = count + npm_args;
var argv = allocator.alloc(string, total) catch return;
var proc: std.ChildProcess = undefined;
@@ -491,7 +491,7 @@ pub const CreateCommand = struct {
[1]Archive.Plucker{undefined};
var archive_context = Archive.Context{
- .pluckers = pluckers[0..@intCast(usize, @intFromBool(!create_options.skip_package_json))],
+ .pluckers = pluckers[0..@as(usize, @intCast(@intFromBool(!create_options.skip_package_json)))],
.all_files = undefined,
.overwrite_list = bun.StringArrayHashMap(void).init(ctx.allocator),
};
@@ -736,7 +736,7 @@ pub const CreateCommand = struct {
if (package_json_expr.asProperty("name")) |name_expr| {
if (name_expr.expr.data == .e_string) {
var basename = std.fs.path.basename(destination);
- name_expr.expr.data.e_string.data = @ptrFromInt([*]u8, @intFromPtr(basename.ptr))[0..basename.len];
+ name_expr.expr.data.e_string.data = @as([*]u8, @ptrFromInt(@intFromPtr(basename.ptr)))[0..basename.len];
}
}
@@ -778,7 +778,7 @@ pub const CreateCommand = struct {
const key = list[i].key.?.data.e_string.data;
const do_prune = packages.has(key);
- prune_count += @intCast(u16, @intFromBool(do_prune));
+ prune_count += @as(u16, @intCast(@intFromBool(do_prune)));
if (!do_prune) {
list[out_i] = list[i];
@@ -902,14 +902,14 @@ pub const CreateCommand = struct {
var needs_to_inject_dev_dependency = needs.react_refresh or needs.bun_macro_relay;
var needs_to_inject_dependency = needs.bun_framework_next;
- const dependencies_to_inject_count = @intCast(usize, @intFromBool(needs.bun_framework_next));
+ const dependencies_to_inject_count = @as(usize, @intCast(@intFromBool(needs.bun_framework_next)));
- const dev_dependencies_to_inject_count = @intCast(usize, @intFromBool(needs.react_refresh)) +
- @intCast(usize, @intFromBool(needs.bun_macro_relay));
+ const dev_dependencies_to_inject_count = @as(usize, @intCast(@intFromBool(needs.react_refresh))) +
+ @as(usize, @intCast(@intFromBool(needs.bun_macro_relay)));
- const new_properties_count = @intCast(usize, @intFromBool(needs_to_inject_dev_dependency and dev_dependencies == null)) +
- @intCast(usize, @intFromBool(needs_to_inject_dependency and dependencies == null)) +
- @intCast(usize, @intFromBool(needs_bun_prop));
+ const new_properties_count = @as(usize, @intCast(@intFromBool(needs_to_inject_dev_dependency and dev_dependencies == null))) +
+ @as(usize, @intCast(@intFromBool(needs_to_inject_dependency and dependencies == null))) +
+ @as(usize, @intCast(@intFromBool(needs_bun_prop)));
if (new_properties_count != 0) {
try properties_list.ensureUnusedCapacity(new_properties_count);
@@ -1835,11 +1835,11 @@ pub const Example = struct {
Headers.Kv{
.name = Api.StringPointer{
.offset = 0,
- .length = @intCast(u32, "Access-Token".len),
+ .length = @as(u32, @intCast("Access-Token".len)),
},
.value = Api.StringPointer{
- .offset = @intCast(u32, "Access-Token".len),
- .length = @intCast(u32, headers_buf.len - "Access-Token".len),
+ .offset = @as(u32, @intCast("Access-Token".len)),
+ .length = @as(u32, @intCast(headers_buf.len - "Access-Token".len)),
},
},
);
diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig
index 0d92c4232..4408568e0 100644
--- a/src/cli/package_manager_command.zig
+++ b/src/cli/package_manager_command.zig
@@ -222,7 +222,7 @@ pub const PackageManagerCommand = struct {
const sorted_dependencies = try ctx.allocator.alloc(DependencyID, root_deps.len);
defer ctx.allocator.free(sorted_dependencies);
for (sorted_dependencies, 0..) |*dep, i| {
- dep.* = @truncate(DependencyID, root_deps.off + i);
+ dep.* = @as(DependencyID, @truncate(root_deps.off + i));
}
std.sort.block(DependencyID, sorted_dependencies, ByName{
.dependencies = dependencies,
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index 271d9ecba..44b3935a3 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -414,7 +414,7 @@ pub const RunCommand = struct {
var retried = false;
if (!strings.endsWithComptime(std.mem.span(std.os.argv[0]), "node")) {
- var argv0 = @ptrCast([*:0]const u8, optional_bun_path.ptr);
+ var argv0 = @as([*:0]const u8, @ptrCast(optional_bun_path.ptr));
// if we are already an absolute path, use that
// if the user started the application via a shebang, it's likely that the path is absolute already
@@ -426,7 +426,7 @@ pub const RunCommand = struct {
var self = std.fs.selfExePath(&self_exe_bin_path_buf) catch unreachable;
if (self.len > 0) {
self.ptr[self.len] = 0;
- argv0 = @ptrCast([*:0]const u8, self.ptr);
+ argv0 = @as([*:0]const u8, @ptrCast(self.ptr));
optional_bun_path.* = self;
}
}
@@ -589,7 +589,7 @@ pub const RunCommand = struct {
try new_path.appendSlice(package_json_dir);
}
- var bin_dir_i: i32 = @intCast(i32, bin_dirs.len) - 1;
+ var bin_dir_i: i32 = @as(i32, @intCast(bin_dirs.len)) - 1;
// Iterate in reverse order
// Directories are added to bin_dirs in top-down order
// That means the parent-most node_modules/.bin will be first
@@ -598,7 +598,7 @@ pub const RunCommand = struct {
if (needs_colon) {
try new_path.append(':');
}
- try new_path.appendSlice(bin_dirs[@intCast(usize, bin_dir_i)]);
+ try new_path.appendSlice(bin_dirs[@as(usize, @intCast(bin_dir_i))]);
}
if (needs_colon) {
diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig
index 5314c6e52..75ca900df 100644
--- a/src/cli/test_command.zig
+++ b/src/cli/test_command.zig
@@ -766,7 +766,7 @@ pub const TestCommand = struct {
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
const file_prefix = if (Output.is_github_action) "::group::" else "";
- vm.main_hash = @truncate(u32, bun.hash(file_path));
+ vm.main_hash = @as(u32, @truncate(bun.hash(file_path)));
var repeat_count = reporter.repeat_count;
var repeat_index: u32 = 0;
while (repeat_index < repeat_count) : (repeat_index += 1) {
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index e9d16999d..b8bfd3f73 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -116,7 +116,7 @@ pub const UpgradeCheckerThread = struct {
}
fn _run(env_loader: *DotEnv.Loader) anyerror!void {
- var rand = std.rand.DefaultPrng.init(@intCast(u64, @max(std.time.milliTimestamp(), 0)));
+ var rand = std.rand.DefaultPrng.init(@as(u64, @intCast(@max(std.time.milliTimestamp(), 0))));
const delay = rand.random().intRangeAtMost(u64, 100, 10000);
std.time.sleep(std.time.ns_per_ms * delay);
@@ -174,8 +174,8 @@ pub const UpgradeCommand = struct {
var header_entries: Headers.Entries = .{};
const accept = Headers.Kv{
- .name = Api.StringPointer{ .offset = 0, .length = @intCast(u32, "Accept".len) },
- .value = Api.StringPointer{ .offset = @intCast(u32, "Accept".len), .length = @intCast(u32, "application/vnd.github.v3+json".len) },
+ .name = Api.StringPointer{ .offset = 0, .length = @as(u32, @intCast("Accept".len)) },
+ .value = Api.StringPointer{ .offset = @as(u32, @intCast("Accept".len)), .length = @as(u32, @intCast("application/vnd.github.v3+json".len)) },
};
try header_entries.append(allocator, accept);
defer if (comptime silent) header_entries.deinit(allocator);
@@ -206,11 +206,11 @@ pub const UpgradeCommand = struct {
Headers.Kv{
.name = Api.StringPointer{
.offset = accept.value.length + accept.value.offset,
- .length = @intCast(u32, "Access-Token".len),
+ .length = @as(u32, @intCast("Access-Token".len)),
},
.value = Api.StringPointer{
- .offset = @intCast(u32, accept.value.length + accept.value.offset + "Access-Token".len),
- .length = @intCast(u32, access_token.len),
+ .offset = @as(u32, @intCast(accept.value.length + accept.value.offset + "Access-Token".len)),
+ .length = @as(u32, @intCast(access_token.len)),
},
},
);
@@ -344,7 +344,7 @@ pub const UpgradeCommand = struct {
if (asset.asProperty("size")) |size_| {
if (size_.expr.data == .e_number) {
- version.size = @intCast(u32, @max(@intFromFloat(i32, std.math.ceil(size_.expr.data.e_number.value)), 0));
+ version.size = @as(u32, @intCast(@max(@as(i32, @intFromFloat(std.math.ceil(size_.expr.data.e_number.value))), 0)));
}
}
return version;