better path resolution

This commit is contained in:
2026-02-20 13:39:26 -06:00
parent 54e5be0773
commit f0c2486a5c
8 changed files with 188 additions and 78 deletions

27
add.ce
View File

@@ -78,29 +78,6 @@ if (!fd.is_file(cwd + '/cell.toml')) {
$stop()
}
// Recursively find all cell packages in a directory
function find_packages(dir) {
var found = []
var list = fd.readdir(dir)
if (!list) return found
if (fd.is_file(dir + '/cell.toml')) {
push(found, dir)
}
arrfor(list, function(item) {
if (item == '.' || item == '..' || item == '.cell' || item == '.git') return
var full = dir + '/' + item
var st = fd.stat(full)
var sub = null
if (st && st.isDirectory) {
sub = find_packages(full)
arrfor(sub, function(p) {
push(found, p)
})
}
})
return found
}
// If -r flag, find all packages recursively and add each
if (recursive) {
if (!locator) {
@@ -111,7 +88,9 @@ if (recursive) {
log.error(`${locator} is not a directory`)
$stop()
}
locators = find_packages(resolved)
locators = filter(pkg.find_packages(resolved), function(p) {
return p != cwd
})
if (length(locators) == 0) {
log.console("No packages found in " + resolved)
$stop()