50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
// cell replace <alias> <path> - Add or update a replace directive for a dependency
|
|
|
|
var fd = use('fd')
|
|
var shop = use('shop')
|
|
|
|
if (args.length < 2) {
|
|
log.console("Usage: cell replace <alias> <path>")
|
|
log.console("Examples:")
|
|
log.console(" cell replace prosperon ../prosperon")
|
|
log.console(" cell replace extramath ../my-fork-of-extramath")
|
|
$_.stop()
|
|
return
|
|
}
|
|
|
|
var alias = args[0]
|
|
var path = args[1]
|
|
|
|
// Initialize shop if needed
|
|
if (!fd.stat('.cell/cell.toml').isFile) {
|
|
log.console("No cell.toml found. Initializing...")
|
|
shop.init()
|
|
}
|
|
|
|
// Load current config
|
|
var config = shop.load_config()
|
|
if (!config) {
|
|
log.error("Failed to load cell.toml")
|
|
$_.stop()
|
|
return
|
|
}
|
|
|
|
// Check if the alias exists in dependencies
|
|
if (!config.dependencies || !config.dependencies[alias]) {
|
|
log.console("Warning: '" + alias + "' is not in dependencies. Adding replace anyway.")
|
|
}
|
|
|
|
// Ensure replace section exists
|
|
if (!config.replace) {
|
|
config.replace = {}
|
|
}
|
|
|
|
// Add or update the replace directive
|
|
config.replace[alias] = path
|
|
shop.save_config(config)
|
|
|
|
log.console("Added replace directive: " + alias + " = " + path)
|
|
log.console("Run 'cell build' to apply changes")
|
|
|
|
$_.stop()
|