MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

read from node_modules for exec first

+23 -1
+23 -1
src/pkg/root.zig
··· 1961 1961 out_path_len: usize, 1962 1962 ) c_int { 1963 1963 const nm_path = std.mem.span(node_modules_path); 1964 - const name = std.mem.span(bin_name); 1964 + const full = std.mem.span(bin_name); 1965 + 1966 + const start: usize = if (full.len > 0 and full[0] == '@') 1967 + (std.mem.indexOfScalar(u8, full[1..], '/') orelse return -1) + 2 1968 + else 0; 1969 + const name, const constraint_str = if (std.mem.indexOfScalar(u8, full[start..], '@')) |i| 1970 + .{ full[0..start + i], full[start + i + 1..] } 1971 + else 1972 + .{ full, @as([]const u8, "") }; 1965 1973 1966 1974 var path_buf: [std.fs.max_path_bytes]u8 = undefined; 1967 1975 const bin_path = std.fmt.bufPrint(&path_buf, "{s}/.bin/{s}", .{ nm_path, name }) catch return -1; 1968 1976 1969 1977 std.fs.cwd().access(bin_path, .{}) catch return -1; 1978 + 1979 + if (constraint_str.len > 0) { 1980 + const constraint = resolver.Constraint.parse(constraint_str) catch return -1; 1981 + if (constraint.kind != .any) { 1982 + var pkg_buf: [std.fs.max_path_bytes]u8 = undefined; 1983 + const pkg_path = std.fmt.bufPrint(&pkg_buf, "{s}/{s}/package.json", .{ nm_path, name }) catch return -1; 1984 + const pkg_path_z = pkg_buf[0..pkg_path.len :0]; 1985 + var doc = json.JsonDoc.parseFile(pkg_path_z) catch return -1; 1986 + defer doc.deinit(); 1987 + const version_str = doc.root().getString("version") orelse return -1; 1988 + const installed = resolver.Version.parse(version_str) catch return -1; 1989 + if (!constraint.satisfies(installed)) return -1; 1990 + } 1991 + } 1970 1992 1971 1993 var real_path_buf: [std.fs.max_path_bytes]u8 = undefined; 1972 1994 const real_path = std.fs.cwd().realpath(bin_path, &real_path_buf) catch return -1;