yeoman - 如何使用 Yeoman 记录彩色消息?

标签 yeoman terminal-color

我试过console.log('message') ,但它以黑色返回消息。

有没有办法在生成器中记录彩色消息?

最佳答案

对于查看此问题的新用户 console.log();根据 Documentation,在 Yeoman 中应该“从不”使用.而是使用 generator.log();在实践中主要被视为 this.log() .

To allow for this flexibility [of running in various user interfaces, not just in terminals], Yeoman provides a set of user interface element abstractions. It is your responsibility as an author to only use those abstractions when interacting with your end user. [Emphasis added.] Using other ways will probably prevent your generator from running correctly in different Yeoman tools.

For example, it is important to never use console.log() or process.stdout.write() to output content. Using them would hide the output from users not using a terminal. Instead, always rely on the UI generic this.log() method, where this is the context of your current generator.

关于yeoman - 如何使用 Yeoman 记录彩色消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18354585/

相关文章:

angularjs - 如何使用 typescript 在 gulp-angular-generator 中定义指令

linux - 如何在 Linux 中更改 echo 的输出颜色

utf-8 - 如何使用 Unicode 将 DOS ANSI (CP 437) 文件转换为 Unix ANSI?

git - 在查看 Git 更改时,如何让终端在 CentOS 7 上显示颜色。?这不是 Git Bash 这只是一个终端窗口

javascript - 如何从 yeoman 输出不需要 grunt 服务即可查看的字典

ruby - compass 路径需要更正

performance - 如何加速 Yeoman 的发球任务?

ubuntu - 哟: command not found