mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: deprecate os.exec (returning ?os.Result), in favour of os.execute, which returns os.Result (#8974)
This commit is contained in:
@ -41,7 +41,7 @@ fn main() {
|
||||
app.backup('cmd/tools/vup.exe')
|
||||
}
|
||||
app.recompile_v()
|
||||
os.exec('"$app.vexe" cmd/tools/vup.v') or { panic(err) }
|
||||
os.execute_or_panic('"$app.vexe" cmd/tools/vup.v')
|
||||
app.show_current_v_version()
|
||||
}
|
||||
|
||||
@ -71,14 +71,13 @@ fn (app App) recompile_v() {
|
||||
opts := if app.is_prod { '-prod' } else { '' }
|
||||
vself := '"$app.vexe" $opts self'
|
||||
app.vprintln('> recompiling v itself with `$vself` ...')
|
||||
if self_result := os.exec(vself) {
|
||||
if self_result.exit_code == 0 {
|
||||
println(self_result.output.trim_space())
|
||||
return
|
||||
} else {
|
||||
app.vprintln('`$vself` failed, running `make`...')
|
||||
app.vprintln(self_result.output.trim_space())
|
||||
}
|
||||
self_result := os.execute(vself)
|
||||
if self_result.exit_code == 0 {
|
||||
println(self_result.output.trim_space())
|
||||
return
|
||||
} else {
|
||||
app.vprintln('`$vself` failed, running `make`...')
|
||||
app.vprintln(self_result.output.trim_space())
|
||||
}
|
||||
app.make(vself)
|
||||
}
|
||||
@ -88,19 +87,19 @@ fn (app App) make(vself string) {
|
||||
$if windows {
|
||||
make = 'make.bat'
|
||||
}
|
||||
make_result := os.exec(make) or { panic(err) }
|
||||
make_result := os.execute_or_panic(make)
|
||||
app.vprintln(make_result.output)
|
||||
}
|
||||
|
||||
fn (app App) show_current_v_version() {
|
||||
if vout := os.exec('"$app.vexe" version') {
|
||||
vout := os.execute('"$app.vexe" version')
|
||||
if vout.exit_code >= 0 {
|
||||
mut vversion := vout.output.trim_space()
|
||||
if vout.exit_code == 0 {
|
||||
latest_v_commit := vversion.split(' ').last().all_after('.')
|
||||
if latest_v_commit_time := os.exec('git show -s --format=%ci $latest_v_commit') {
|
||||
if latest_v_commit_time.exit_code == 0 {
|
||||
vversion += ', timestamp: ' + latest_v_commit_time.output.trim_space()
|
||||
}
|
||||
latest_v_commit_time := os.execute('git show -s --format=%ci $latest_v_commit')
|
||||
if latest_v_commit_time.exit_code == 0 {
|
||||
vversion += ', timestamp: ' + latest_v_commit_time.output.trim_space()
|
||||
}
|
||||
}
|
||||
println('Current V version:')
|
||||
@ -118,10 +117,11 @@ fn (app App) backup(file string) {
|
||||
|
||||
fn (app App) git_command(command string) {
|
||||
app.vprintln('git_command: git $command')
|
||||
git_result := os.exec('git $command') or {
|
||||
git_result := os.execute('git $command')
|
||||
if git_result.exit_code < 0 {
|
||||
app.get_git()
|
||||
// Try it again with (maybe) git installed
|
||||
os.exec('git $command') or { panic(err) }
|
||||
os.execute_or_panic('git $command')
|
||||
}
|
||||
if git_result.exit_code != 0 {
|
||||
eprintln(git_result.output)
|
||||
@ -134,13 +134,15 @@ fn (app App) get_git() {
|
||||
$if windows {
|
||||
println('Downloading git 32 bit for Windows, please wait.')
|
||||
// We'll use 32 bit because maybe someone out there is using 32-bit windows
|
||||
os.exec('bitsadmin.exe /transfer "vgit" https://github.com/git-for-windows/git/releases/download/v2.30.0.windows.2/Git-2.30.0.2-32-bit.exe "$os.getwd()/git32.exe"') or {
|
||||
res_download := os.execute('bitsadmin.exe /transfer "vgit" https://github.com/git-for-windows/git/releases/download/v2.30.0.windows.2/Git-2.30.0.2-32-bit.exe "$os.getwd()/git32.exe"')
|
||||
if res_download.exit_code != 0 {
|
||||
eprintln('Unable to install git automatically: please install git manually')
|
||||
panic(err)
|
||||
panic(res_download.output)
|
||||
}
|
||||
os.exec('$os.getwd()/git32.exe') or {
|
||||
res_git32 := os.execute('$os.getwd()/git32.exe')
|
||||
if res_git32.exit_code != 0 {
|
||||
eprintln('Unable to install git automatically: please install git manually')
|
||||
panic(err)
|
||||
panic(res_git32.output)
|
||||
}
|
||||
} $else { // Probably some kind of *nix, usually need to get using a package manager.
|
||||
eprintln("error: Install `git` using your system's package manager")
|
||||
|
Reference in New Issue
Block a user