BPM-for-Discord
BPM-for-Discord copied to clipboard
Allow Node versions higher than 4.2.X to be used to install (Issue #58)
Since @ByzantineFailure asked for a PR, here it is! A bit of a breakdown of how this works.
$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)
Let's have a look inside of this block, first.
-
echo "$@"
- First we print all the arguments of the version_ge function -
tr " " "\n"
- We replace all spaces (which would be the separator between version numbers at the moment like "8.1.4 4.2.0") to newlines. Each version on it's own line. -
sort -rV
- We use the sort command to sort by version numbers, in reverse, so the newer version is the top string. -
head -n 1
- Finally, this will output the top string.
test "[above block]" == "$1";
- This then checks if the output of the block above is equal to the first argument of the function, a.k.a. the version of Node already on the computer. If it's equal, the host Node is new enough! This will return true if it is.
NODE_VERSION=$(node --version | cut -c2-)
- This is pretty simple, we get the Node version and cut off the first character, or the "v" in front of the numbers. Otherwise it messes things up.
if version_ge $NODE_VERSION "4.2.0"; then
- This one should be pretty simple too. If the Node version is greater or equal to 4.2.0, then we've met the requirements and will use the native Node install.
Perhaps we should have a link to the PR explaining this as a comment in the script or something.
I tested the script against Node 4.2.0 and Node 0.10.2 and it does reject them and grab Node 4.2. So that works, even if it did pain me to run such old copies of Node on my system
Recent Node.js versions (tested with 8.9.3 and 9.2.0) seem to work fine for installing the latest BPM version, but this pull request seems to have stalled. Should I send another pull request?
Besides, the downloaded Node.js version should be updated as 4.2.4 is very old by now.
I can resubmit the PR on an updated copy of BPM for Discord to get rid of the conflicts, but I still don't have a Windows machine to test on, nor do I know anything about PowerShell or much about batch. Can anyone help out with the Windows side at all?
I should look into doing this, I suppose.
Can you resubmit a PR that pins it to the latest LTS version? I'll need to update the build process to do the same but it shouldn't be an enormous deal.
Yeah, I could. Can you wait until tonight or tomorrow in the afternoon? I'm having to catch up on a lot of work today.