centralized ensure dir

This commit is contained in:
2026-02-20 15:02:16 -06:00
24 changed files with 341 additions and 949 deletions

View File

@@ -6,16 +6,6 @@ var link = use('link')
var global_shop_path = runtime.shop_path
// Convert package name to a safe directory name
// For absolute paths (local packages), replace / with _
// For remote packages, keep slashes as they use nested directories
function safe_package_path(pkg) {
if (!pkg) return pkg
if (starts_with(pkg, '/'))
return replace(replace(pkg, '/', '_'), '@', '_')
return replace(pkg, '@', '_')
}
function get_path(name)
{
// If name is null, return the current project directory
@@ -33,11 +23,11 @@ function get_path(name)
if (starts_with(link_target, '/'))
return link_target
// Otherwise it's another package name, resolve that
return global_shop_path + '/packages/' + replace(replace(link_target, '/', '_'), '@', '_')
return global_shop_path + '/packages/' + fd.safe_package_path(link_target)
}
// Remote packages use nested directories, so don't transform slashes
return global_shop_path + '/packages/' + replace(name, '@', '_')
return global_shop_path + '/packages/' + fd.safe_package_path(name)
}
var config_cache = {}