diff --git a/package.cm b/package.cm index b0e3cb04..5a9defe3 100644 --- a/package.cm +++ b/package.cm @@ -5,6 +5,9 @@ var json = use('json') var os = use('os') var link = use('link') +// Cache for loaded configs to avoid toml re-parsing corruption +var config_cache = {} + // 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 @@ -43,6 +46,10 @@ package.load_config = function(name) { var config_path = get_path(name) + '/cell.toml' + // Return cached config if available + if (config_cache[config_path]) + return config_cache[config_path] + if (!fd.is_file(config_path)) { throw Error(`${config_path} does not exist`) } @@ -56,6 +63,10 @@ package.load_config = function(name) return {} } + // Deep copy to avoid toml module's shared state bug and cache it + result = json.decode(json.encode(result)) + config_cache[config_path] = result + return result } diff --git a/update.ce b/update.ce index eb39c5a3..06d0db5d 100644 --- a/update.ce +++ b/update.ce @@ -120,7 +120,7 @@ if (target_pkg) { } } - if (length(updated_packages)) > 0) { + if (length(updated_packages) > 0) { log.console("Updated " + text(length(updated_packages)) + " package" + (length(updated_packages) == 1 ? "" : "s") + ".") } else { log.console("All packages are up to date.") @@ -135,13 +135,12 @@ if (run_build && length(updated_packages) > 0) { arrfor(updated_packages, function(pkg) { try { var lib = build.build_dynamic(pkg, target_triple, 'release') - if (lib) { + if (lib) log.console(" Built: " + lib) - } } catch (e) { log.error(" Failed to build " + pkg + ": " + e) } - }, null, null) + }) } $stop()