We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 602a056 commit 514ee8dCopy full SHA for 514ee8d
src/index.js
@@ -33,12 +33,15 @@ function iPipeTo(
33
function trim(str) {
34
const maxWidth = cliWidth({ defaultWidth: 80, output: stdout }) - 9;
35
36
- let attempts = 0
37
- while (stringWidth(str) > maxWidth) {
38
- // trim until shorter than maxWidth
39
- str = str.substr(0, maxWidth - ++attempts)
+ if (str.length > maxWidth) {
+ let attempts = 0
+ while (stringWidth(str) > maxWidth) {
+ // trim until shorter than maxWidth
40
+ str = str.substr(0, maxWidth - ++attempts)
41
+ }
42
+ str += "..."
43
}
- str += "..."
44
+
45
return str
46
47
0 commit comments