Closed sunnylost closed 9 years ago
var Chalk = require( 'chalk' ), Yosay = require( 'yosay' ), StringLength = require( 'string-length' ), message = [] var newVersion = Chalk.green.bold( '1.0.3' ), curVersion = Chalk.gray( ' (current: 1.0.1)' ), command = Chalk.magenta( 'sudo npm install -g cage' ) message.push( '项目可以更新了: ' + newVersion + curVersion ) message.push( '运行' + command + ' to update' ) console.log( Yosay( message.join( ' ' ), { maxLength: StringLength( message[ 0 ] ) } ) )
Result:
_-----_ | | .---------------------------------. |--(o)--| | 项目可以更新了: 1.0.3 (current: 1.0.1) | `---------´ | 运行sudo npm install -g cage to | ( _´U`_ ) | update | /___A___\ '---------------------------------' | ~ | __'.___.'__ ´ ` |° ´ Y `
This is fixed in 1.0.5. Use string-width instead of string-length.
string-length
Result: