fix
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
var fd = use('fd')
|
||||
var shop = use('shop')
|
||||
var miniz = use('miniz')
|
||||
var http = use('http')
|
||||
|
||||
if (args.length < 1) {
|
||||
log.console("Usage: cell get <locator> [alias]")
|
||||
@@ -17,42 +15,15 @@ if (args.length < 1) {
|
||||
var locator = args[0]
|
||||
var parsed = shop.parse_locator(locator)
|
||||
|
||||
var config = shop.load_config()
|
||||
if (!config) {
|
||||
log.error("Failed to load cell.toml")
|
||||
$_.stop()
|
||||
return
|
||||
}
|
||||
|
||||
// Use the module name as the default alias
|
||||
var alias = parsed.name
|
||||
if (args.length > 1)
|
||||
alias = args[1]
|
||||
|
||||
if (!alias) {
|
||||
log.error("Failed to determine alias")
|
||||
$_.stop()
|
||||
return
|
||||
}
|
||||
if (!alias)
|
||||
throw new Error("Failed to determine alias");
|
||||
|
||||
// Check if already exists
|
||||
if (config.dependencies && config.dependencies[alias]) {
|
||||
log.console("Dependency '" + alias + "' already exists with version: " + config.dependencies[alias])
|
||||
log.console("Use 'cell update " + alias + "' to change version")
|
||||
$_.stop()
|
||||
return
|
||||
}
|
||||
|
||||
// Add to dependencies
|
||||
log.console("Adding dependency: " + alias + " = " + locator)
|
||||
shop.add_dependency(alias, locator)
|
||||
|
||||
// Create module directory
|
||||
var module_dir = '.cell/modules/' + alias + '@' + parsed.version
|
||||
if (!fd.is_directory(module_dir))
|
||||
fd.mkdir(module_dir)
|
||||
|
||||
// TODO: Actually fetch the module from the repository
|
||||
log.console("Module directory created at: " + module_dir)
|
||||
|
||||
$_.stop()
|
||||
@@ -36,7 +36,6 @@ Shop.set_os = function(o)
|
||||
var config = null
|
||||
|
||||
var shop_path = '.cell/cell.toml'
|
||||
var lock_path = '.cell/lock.toml'
|
||||
|
||||
var open_dl = {}
|
||||
|
||||
@@ -144,6 +143,7 @@ Shop.load_config = function(module) {
|
||||
content = fd.slurp(module_path)
|
||||
}
|
||||
|
||||
if (!content.length) return {}
|
||||
return toml.decode(text(content))
|
||||
}
|
||||
|
||||
@@ -275,14 +275,14 @@ Shop.get_download_url = function(locator) {
|
||||
// Add a dependency
|
||||
Shop.add_dependency = function(alias, locator) {
|
||||
var config = Shop.load_config()
|
||||
if (!config) {
|
||||
log.error("No cell.toml found")
|
||||
return false
|
||||
}
|
||||
if (!config)
|
||||
throw new Error("No cell.toml found");
|
||||
|
||||
if (!config.dependencies) {
|
||||
if (!config.dependencies)
|
||||
config.dependencies = {}
|
||||
}
|
||||
|
||||
if (config.dependencies[alias] == locator)
|
||||
throw new Error("Dependency '" + alias + "' already exists with the same version");
|
||||
|
||||
config.dependencies[alias] = locator
|
||||
Shop.save_config(config)
|
||||
@@ -508,8 +508,6 @@ var open_dls = {}
|
||||
|
||||
function resolve_locator(path, ext, ctx)
|
||||
{
|
||||
var deps = Shop.load_config(ctx).dependencies || {}
|
||||
|
||||
var local_path
|
||||
if (ctx)
|
||||
local_path = `.cell/modules/${ctx}/${path}${ext}`
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// cell update - Check for updates
|
||||
var shop = use('shop')
|
||||
|
||||
log.console("Checking for updates...")
|
||||
shop.update()
|
||||
$_.stop()
|
||||
Reference in New Issue
Block a user