dylang / grunt-attention

Display attention-grabbing messages in the terminal.

Home Page:https://npmjs.org/package/grunt-attention

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Long messages cause a confusing error

NickHeiner opened this issue · comments

Using the following grunt config:

        attention: {
            'repro-bug': {
                options: {
                    message: 'this_is_a_very_very_very_very_very_very_very_very_very_very_very_very_long_message'
                }
            }
        },

and a small terminal window:

small terminal

One gets the following unhelpful error:

Warning: Invalid array length Use --force to continue.
RangeError: Invalid array length
    at repeat (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/x-web-taskmaster/node_modules/grunt-attention/lib/generate-message.js:8:12)
    at message (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/x-web-taskmaster/node_modules/grunt-attention/lib/generate-message.js:39:66)
    at Array.map (native)
    at attention (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/x-web-taskmaster/node_modules/grunt-attention/lib/generate-message.js:36:26)
    at displayMessage (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/x-web-taskmaster/node_modules/grunt-attention/tasks/attention.js:17:31)
    at Object.<anonymous> (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/x-web-taskmaster/node_modules/grunt-attention/tasks/attention.js:29:16)
    at Object.<anonymous> (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/grunt/lib/grunt/task.js:264:15)
    at Object.thisTask.fn (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.<anonymous> (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/grunt/lib/util/task.js:301:30)
    at Task.runTaskFn (/Users/nick.heiner/opower/grunt-x-web-server/node_modules/grunt/lib/util/task.js:251:24)

The error comes from this line:

function repeat(str, count) {
    // count is negative
    return new Array(count).join(str);
}

Great find, hope that wasn't blocking you. Bumped npm version to 1.0.0 to be on semver.

Thanks!