当我在我的项目目录中运行某个grunt任务时,以下是来自Windows PowerShell的一些示例输出:
Done, without errors.
Execution Time (2015-08-25 01:57:14 UTC)
loading tasks 9ms ██████ 17%
loading grunt-contrib-copy 23ms ███████████████ 43%
copy:styles 20ms █████████████ 38%
Total 53ms
Running "autoprefixer:server" (autoprefixer) task
Autoprefixer's process() method is deprecated and will removed in next major release. Use postcss([autoprefixe
r]).process() instead
File .tmp/styles/main.css created.
“完成,无错误”显示为绿色,“.tmp/styles/main.css”显示为青色。在Powershell ISE中运行相同的命令,会产生以下结果:
[32mDone, without errors.[39m
Execution Time (2015-08-25 01:58:40 UTC)
loading tasks 9ms ███████ 20%
loading grunt-contrib-copy 20ms ████████████████ 45%
copy:styles 14ms ███████████ 32%
Total 44ms
[4mRunning "autoprefixer:server" (autoprefixer) task[24m
grunt : Autoprefixer's process() method is deprecated and will removed in next major release. Use
postcss([autoprefixer]).process() instead
At line:1 char:1
+ grunt serve
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Autoprefixer's ...ocess() instead:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
File .tmp/styles/main.css created.
颜色和非ASCII字符都没有被正确地解释。
我尝试过搜索解决方案,但没有成功。如何使PowerShell ISE的行为更像PowerShell?听起来PS ISE只是常规 PS 的包装器,但肯定还有更多内容。
更新:发现这篇文章说“控制台应用程序输出不是彩色的”。这是否意味着无法通过PowerShell ISE获得类似于PowerShell的输出?
Read-Host
调用,这将会引起问题。 - jpmc26Read-Host
的调用通常会创建一个提示窗口,在该窗口中您可以输入(因为您无法在ISE的输出窗口上输入),但是如果您从脚本中启动了单独的PowerShell进程,则不会出现该窗口。请参见我的回答在这里。 - jpmc26Read-Host
在控制台主机中工作;它只是不会弹出新窗口,而是让你直接输入。在阅读了你的答案之后,看起来你正在ISE中运行powershell.exe
(这意味着它正在共享ISE的“控制台”窗口)。在我的方法中,我使用Start-Process
特别是因为它打开一个全新的powershell.exe
实例,在它自己的控制台主机中。 - briantist