summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-12-20 23:59:40 +0800
committerruki <[email protected]>2019-12-20 17:58:04 +0800
commitec7035398c3ad32ccca6d29b96895864d1802fb2 (patch)
tree2d26dfef891c86eb3f81cc55a44b15fbab75fdb3
parentb8ef2fa1fdf5d7dcd2b8d076f479bbfbad1a0738 (diff)
hide wait progress info when redirecting
-rw-r--r--xmake/actions/require/impl/package.lua6
-rw-r--r--xmake/core/base/process.lua32
-rw-r--r--xmake/core/sandbox/modules/utils.lua5
3 files changed, 33 insertions, 10 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 8983d8ea5..4640cfaf6 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -527,6 +527,10 @@ end
-- install packages
function _install_packages(packages_install, packages_download)
+ -- we need hide wait characters if is not a tty
+ local show_wait = io.isatty()
+
+ -- do install
local waitindex = 0
local waitchars = {'\\', '-', '/', '|'}
local packages_installing = {}
@@ -630,7 +634,7 @@ function _install_packages(packages_install, packages_download)
end, #packages_install, (option.get("verbose") or option.get("diagnosis")) and 1 or 4, 300, function (indices, tips)
-- do not print progress info if be verbose
- if option.get("verbose") then
+ if option.get("verbose") or not show_wait then
return
end
diff --git a/xmake/core/base/process.lua b/xmake/core/base/process.lua
index ff8336a6d..65be506a9 100644
--- a/xmake/core/base/process.lua
+++ b/xmake/core/base/process.lua
@@ -23,6 +23,7 @@ local process = process or {}
local _subprocess = _subprocess or {}
-- load modules
+local io = require("base/io")
local path = require("base/path")
local utils = require("base/utils")
local string = require("base/string")
@@ -161,10 +162,15 @@ function process.asyncrun(task, waitchars)
-- create a coroutine task
task = coroutine.create(task)
+ -- we need hide wait characters if is not a tty
+ local show_wait = io.isatty()
+
-- trace
local waitindex = 0
local waitchars = waitchars or {'\\', '-', '/', '|'}
- utils.printf(waitchars[waitindex + 1])
+ if show_wait then
+ utils.printf(waitchars[waitindex + 1])
+ end
io.flush()
-- start and wait this task
@@ -172,8 +178,10 @@ function process.asyncrun(task, waitchars)
if not ok then
-- remove wait charactor
- utils.printf("\b")
- io.flush()
+ if show_wait then
+ utils.printf("\b")
+ io.flush()
+ end
-- failed
return false, errors
@@ -183,8 +191,10 @@ function process.asyncrun(task, waitchars)
while coroutine.status(task) ~= "dead" do
-- trace
- waitindex = ((waitindex + 1) % #waitchars)
- utils.printf("\b" .. waitchars[waitindex + 1])
+ if show_wait then
+ waitindex = ((waitindex + 1) % #waitchars)
+ utils.printf("\b" .. waitchars[waitindex + 1])
+ end
io.flush()
-- wait some time
@@ -195,8 +205,10 @@ function process.asyncrun(task, waitchars)
if not ok then
-- remove wait charactor
- utils.printf("\b")
- io.flush()
+ if show_wait then
+ utils.printf("\b")
+ io.flush()
+ end
-- failed
return false, errors
@@ -204,8 +216,10 @@ function process.asyncrun(task, waitchars)
end
-- remove wait charactor
- utils.printf("\b")
- io.flush()
+ if show_wait then
+ utils.printf("\b")
+ io.flush()
+ end
-- ok
return true
diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua
index a28ec1b8a..485622336 100644
--- a/xmake/core/sandbox/modules/utils.lua
+++ b/xmake/core/sandbox/modules/utils.lua
@@ -170,6 +170,11 @@ end
-- clear the current terminal line
function sandbox_utils.clearline()
+ -- we need not clear line if is not a tty
+ if not io.isatty() then
+ return
+ end
+
-- get empty line chars
local emptychars = sandbox_utils._EMPTYCHARS
if not emptychars then