mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
only if dir exists
This commit is contained in:
@@ -1100,7 +1100,7 @@ pub const PathName = struct {
|
||||
}
|
||||
|
||||
if (comptime Environment.allow_assert) {
|
||||
std.debug.assert(!strings.includes(self.base, "/"));
|
||||
if (self.dir.len > 0) std.debug.assert(!strings.includes(self.base, "/"));
|
||||
}
|
||||
|
||||
// /bar/foo.js -> foo
|
||||
|
||||
@@ -224,6 +224,16 @@ pub fn indexOfSigned(self: string, str: string) i32 {
|
||||
}
|
||||
|
||||
pub inline fn lastIndexOfChar(self: string, char: u8) ?usize {
|
||||
if (comptime Environment.isLinux) {
|
||||
const memrchr = struct {
|
||||
pub extern fn memrchr(ptr: [*]const u8, val: c_int, len: usize) ?[*]const u8;
|
||||
}.memrchr;
|
||||
const start = memrchr(self.ptr, char, self.len) orelse return null;
|
||||
const i = @ptrToInt(start) - @ptrToInt(self.ptr);
|
||||
std.debug.assert(i < self.len);
|
||||
return @intCast(usize, i);
|
||||
}
|
||||
|
||||
return std.mem.lastIndexOfScalar(u8, self, char);
|
||||
}
|
||||
|
||||
|
||||
@@ -5953,9 +5953,9 @@ describe("bundler", () => {
|
||||
'Could not resolve: "@scope/pkg4". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "@scope/pkg5/foo". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "@abs-path/pkg6". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "@abs-path/pkg6/foo". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "@abs-path/pkg7/foo". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "@scope-only/pkg8". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "slash/" Maybe. you need to "bun install"?',
|
||||
'Could not resolve: "slash/". Maybe you need to "bun install"?',
|
||||
'Could not resolve: "pkg3". Maybe you need to "bun install"?',
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user