diff options
| author | 2023-01-25 01:52:04 -0800 | |
|---|---|---|
| committer | 2023-01-25 01:52:04 -0800 | |
| commit | 468226fc902390bc5c57711fe4d9a3320599f0ab (patch) | |
| tree | 64f81addad69b2fb0cb5aaad2571659b25cabe0e /src/install/npm.zig | |
| parent | 9cb1ec2c589cbaf33e176e539cc4c9f28f84d9fe (diff) | |
| download | bun-468226fc902390bc5c57711fe4d9a3320599f0ab.tar.gz bun-468226fc902390bc5c57711fe4d9a3320599f0ab.tar.zst bun-468226fc902390bc5c57711fe4d9a3320599f0ab.zip | |
be more careful
Diffstat (limited to 'src/install/npm.zig')
| -rw-r--r-- | src/install/npm.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/install/npm.zig b/src/install/npm.zig index 3301b2653..79dea81ce 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -407,6 +407,13 @@ pub const PackageVersion = extern struct { os: OperatingSystem = OperatingSystem.all, /// `"cpu"` field in package.json cpu: Architecture = Architecture.all, + + pub fn verify(this: *const PackageVersion) void { + if (comptime !Environment.allow_assert) + return; + + this.man_dir.value.assertDefined(); + } }; pub const NpmPackage = extern struct { @@ -440,6 +447,23 @@ pub const PackageManifest = struct { package_versions: []const PackageVersion = &[_]PackageVersion{}, extern_strings_bin_entries: []const ExternalString = &[_]ExternalString{}, + pub fn verify(this: *const PackageManifest) void { + if (comptime !Environment.allow_assert) + return; + + for (this.extern_strings_bin_entries) |*entry| { + entry.value.assertDefined(); + } + + for (this.external_strings_for_versions) |entry| { + entry.value.assertDefined(); + } + + for (this.package_versions) |package| { + package.tarball_url.value.assertDefined(); + } + } + pub inline fn name(this: *const PackageManifest) string { return this.pkg.name.slice(this.string_buf); } @@ -617,6 +641,8 @@ pub const PackageManifest = struct { } } + package_manifest.verify(); + return package_manifest; } }; |
