dsifford / yarn-completion

Bash completion for Yarn
MIT License
277 stars 25 forks source link

head: illegal line count #3

Closed wavded closed 7 years ago

wavded commented 7 years ago

Thanks for working on this. I noticed an issue when typing the following:

$ yarn remove <tab>

I get:

yarn remove head: illegal line count -- -1
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]

Running MacOS Sierra, Bash 4.4.12, grep (BSD grep) 2.5.1-FreeBSD

wavded commented 7 years ago

Turns out this was an issue in BSD head program. If I overwrite with the GNU head, it works great.

Had to do the following:

brew install coreutils

And then add the following to my bash_profile:

hash ghead >/dev/null 2>&1 && alias head="ghead"

BSD head did not support negative line numbers found in this command:

        head -n -1 |
dsifford commented 7 years ago

@wavded hmm... I think I have an idea what the issue might be.

Can you confirm that the package.json in the directory that have you the error is missing either dependencies or devDependencies?

dsifford commented 7 years ago

Aha... Very strange! Thanks for the report. I'll see if I can change out that line to something that's a bit more cross-compatible later on when I get some free time. 👌

dsifford commented 7 years ago

@wavded FYI, just got around to checking this. The issue is because I assume that all package.json files contain both dependencies and devDependencies. If a user queries upgrade or remove in a directory that contains a package.json without both of these fields, it'll throw that exception.

Once I fix this, it should work with BSD head and tail. 👍 👍

dsifford commented 7 years ago

Just kidding. You were totally right. v1.0.2 should cover this issue completely. Thanks for the report.