This commit is contained in:
parent
de2b630346
commit
174debf2da
3 changed files with 22 additions and 8 deletions
|
@ -23,6 +23,10 @@ fn Cache.default() !Cache {
|
|||
return Cache.new(cache_dir)
|
||||
}
|
||||
|
||||
fn (c Cache) dir_no_create(name ...string) !string {
|
||||
return os.join_path(c.base_path, ...name)
|
||||
}
|
||||
|
||||
fn (c Cache) path(name ...string) !string {
|
||||
dir := os.join_path(c.base_path, ...name)
|
||||
os.mkdir_all(dir) or { return error('failed to create directory ${dir}') }
|
||||
|
|
|
@ -32,7 +32,7 @@ const install_command = cli.Command{
|
|||
}
|
||||
|
||||
fn execute_install(cmd cli.Command) ! {
|
||||
if cmd.flags.get_bool('debug') or { false } {
|
||||
if cmd.flags.get_bool('verbose') or { false } {
|
||||
log.set_level(.debug)
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ fn UChromium.new(cache Cache) !UChromium {
|
|||
}
|
||||
|
||||
fn (u UChromium) repo_path() !string {
|
||||
return u.cache.path('uchromium-repo')
|
||||
return u.cache.dir_no_create('uchromium-repo')
|
||||
}
|
||||
|
||||
fn (u UChromium) set_repo() ! {
|
||||
|
@ -75,10 +75,12 @@ fn (u UChromium) set_repo() ! {
|
|||
}
|
||||
}
|
||||
|
||||
os.execute_opt(cmd) or {
|
||||
res := os.execute_opt(cmd) or {
|
||||
return error('failed to sync ${uchromium_repo} to ${repo_path}: ${err}')
|
||||
}
|
||||
|
||||
log.debug('res: ${res}')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -96,13 +98,11 @@ fn (u UChromium) find_version(version string) !UChromiumVersion {
|
|||
b_parts := b.split_any('.-/')
|
||||
|
||||
for i in 0 .. math.min(a_parts.len, b_parts.len) {
|
||||
return if a_parts[i].int() < b_parts[i].int() {
|
||||
-1
|
||||
} else if a_parts[i].int() > b_parts[i].int() {
|
||||
1
|
||||
} else {
|
||||
if a_parts[i] == b_parts[i] {
|
||||
continue
|
||||
}
|
||||
|
||||
return compare_ints(a_parts[i].int(), b_parts[i].int())
|
||||
}
|
||||
|
||||
return 0
|
||||
|
@ -154,3 +154,13 @@ fn (u UChromium) install(version string, install_to string) ! {
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
fn compare_ints(a int, b int) int {
|
||||
return if a < b {
|
||||
-1
|
||||
} else if a > b {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue