<commit_before>#!/bin/bash
# By <NAME>

# 2017-04-20 Getting latest NodeJs version by <NAME> (KeesTalksTech)
# Based on script by <NAME> @ https://github.com/audstanley/Node-MongoDb-Pi/

#get pi ARM version
PI_ARM_VERSION=$(
  uname -a | 
  egrep 'armv[0-9]+l' -o
);

NODE_VERSION=$1

if [ -z "$NODE_VERSION" ] || [ "$NODE_VERSION" = "stable" ]; then
#get latest nodejs version from node website
#read the first version that matches the arm platform
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v([0-9]+\.?){3}\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*lts:\"[^}]*}" -o |
  head -n 1
);
elif [ "$NODE_VERSION" = "latest" ]; then
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v([0-9]+\.?){3}\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*}" -o |
  head -n 1
);
else 
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v$NODE_VERSION\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*}" -o |
  head -n 1
);
fi

echo "Node version: $NODE_VERSION"

#get the version
VERSION=$(
  echo $NODE_VERSION | 
  egrep 'v([0-9]+\.?){3}' -o
);

echo "Version: $VERSION"

#get lts version
LTS_VERSION=$(echo $NODE_VERSION | 
  egrep '"[^"]+"$' -o | 
  egrep '[a-zA-Z]+' -o | <commit_msg>Fixes regex for version selection with LTS<commit_after>#!/bin/bash
# By <NAME>

# 2017-04-20 Getting latest NodeJs version by <NAME> (KeesTalksTech)
# Based on script by <NAME> @ https://github.com/audstanley/Node-MongoDb-Pi/

#get pi ARM version
PI_ARM_VERSION=$(
  uname -a | 
  egrep 'armv[0-9]+l' -o
);

NODE_VERSION=$1

if [ -z "$NODE_VERSION" ] || [ "$NODE_VERSION" = "stable" ]; then
#get latest nodejs version from node website
#read the first version that matches the arm platform
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v([0-9]+\.?){3}\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*lts\":\"[^}]*}" -o |
  head -n 1
);
elif [ "$NODE_VERSION" = "latest" ]; then
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v([0-9]+\.?){3}\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*}" -o |
  head -n 1
);
else 
NODE_VERSION=$(
  curl https://nodejs.org/dist/index.json | 
  egrep "{\"version\":\"v$NODE_VERSION\"[^{]*\"linux-"$PI_ARM_VERSION"[^}]*}" -o |
  head -n 1
);
fi

echo "Node version: $NODE_VERSION"

#get the version
VERSION=$(
  echo $NODE_VERSION | 
  egrep 'v([0-9]+\.?){3}' -o
);

echo "Version: $VERSION"

#get lts version
LTS_VERSION=$(echo $NODE_VERSION | 
  egrep '"[^"]+"$' -o | 
  egrep '[a-zA-Z]+' -o | 
{'fraction_non_alphanumeric': 0.23552579755809375, 'fraction_numerical': 0.01811736904293029, 'mean_word_length': 3.8473282442748094, 'pattern_counts': {'":': 7, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7270947', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1007, 'n_words': 224}