我试过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()
orprocess.stdout.write()
to output content. Using them would hide the output from users not using a terminal. Instead, always rely on the UI genericthis.log()
method, wherethis
is the context of your current generator.
关于yeoman - 如何使用 Yeoman 记录彩色消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18354585/