diff --git a/cli.js b/cli.js index c216295..b41a9a6 100755 --- a/cli.js +++ b/cli.js @@ -44,7 +44,7 @@ if (argv.l) { } else if (argv._.length) { say(); } else { - require("get-stdin")(function (data) { + require("get-stdin")().then(function (data) { if (data) { argv._ = [data]; say(); diff --git a/lib/balloon.js b/lib/balloon.js index e79de05..8f80a92 100644 --- a/lib/balloon.js +++ b/lib/balloon.js @@ -1,3 +1,5 @@ +var stringWidth = require("string-width"); + exports.say = function (text, wrap) { var delimiters = { first : ["/", "\\"], @@ -83,8 +85,8 @@ function split (text, wrap) { function max (lines) { var max = 0; for (var i = 0, len = lines.length; i < len; i += 1) { - if (lines[i].length > max) { - max = lines[i].length; + if (stringWidth(lines[i]) > max) { + max = stringWidth(lines[i]); } } @@ -92,7 +94,7 @@ function max (lines) { } function pad (text, length) { - return text + (new Array(length - text.length + 1)).join(" "); + return text + (new Array(length - stringWidth(text) + 1)).join(" "); } function top (length) { diff --git a/package.json b/package.json index adc85d3..e0782a1 100644 --- a/package.json +++ b/package.json @@ -40,13 +40,14 @@ "test": "node test.js" }, "dependencies": { - "get-stdin": "^4.0.1", - "optimist": "~0.6.1" + "get-stdin": "^5.0.1", + "optimist": "~0.6.1", + "string-width": "~2.1.1" }, "devDependencies": { "nodeunit": "~0.11.1", - "rollup": "^0.47.4", - "rollup-plugin-commonjs": "^8.1.0", + "rollup": "^0.48.2", + "rollup-plugin-commonjs": "^8.2.0", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-string": "^2.0.2" }, diff --git a/rollup.config.js b/rollup.config.js index d87094c..53a4190 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,7 +3,7 @@ import nodeResolve from 'rollup-plugin-node-resolve'; import string from 'rollup-plugin-string'; export default { - entry: 'browser.js', + input: 'browser.js', plugins: [ nodeResolve({ module: true, @@ -14,9 +14,9 @@ export default { include: '**/*.cow', }), ], - moduleName: 'cowsay', - targets: [ - { dest: 'build/cowsay.umd.js', format: 'umd' }, - { dest: 'build/cowsay.es.js', format: 'es' }, + name: 'cowsay', + output: [ + { file: 'build/cowsay.umd.js', format: 'umd' }, + { file: 'build/cowsay.es.js', format: 'es' }, ] }