<commit_before>#!/bin/sh

set -e

is_executable () {
  command -v "$1" >/dev/null 2>&1
}

errcho () {
  >&2 echo "$@"
}

echo "# Installing slap..."

if ! (is_executable npm && is_executable node && is_executable git); then
  if is_executable brew; then
    brew install node git
  elif is_executable port; then
    port install nodejs git
  elif is_executable apt-get; then
    if ! is_executable wget; then
      errcho "wget not available. Please install wget first, then run this script again."
      exit 1
    fi
    wget -qO- https://deb.nodesource.com/setup | sudo bash - # Adds NodeSource repository to dpkg
    sudo apt-get install -y nodejs git
  elif is_executable yum; then
    if ! is_executable curl; then
      errcho "curl not available. Please install curl first, then run this script again."
      exit 1
    fi
    curl -sL https://rpm.nodesource.com/setup | bash - # Adds NodeSource repository to yum
    sudo yum install -y nodejs git
  elif is_executable emerge; then
    emerge nodejs git
  elif is_executable pacman; then
    pacman -S nodejs npm git
  else
    errcho "Couldn't determine OS. Please install NodeJS manually, then run this script again."
    errcho "Visit https://github.com/joyent/node/wiki/installing-node.js-via-package-manager for instructions on how to install NodeJS on your OS."
    exit 1
  fi
fi

is_executable python2 && PYTHON='python2'
maybe_sudo="$([ -w "$(npm get prefix)/lib/node_modules" ] || echo 'sudo')"
$maybe_sudo npm install -g slap@latest<commit_msg>Upgrade deprecated install script<commit_after>#!/bin/sh

set -e

is_executable () {
  command -v "$1" >/dev/null 2>&1
}

errcho () {
  >&2 echo "$@"
}

echo "# Installing slap..."

if ! (is_executable npm && is_executable node && is_executable git); then
  if is_executable brew; then
    brew install node git
  elif is_executable port; then
    port install nodejs git
  elif is_executable apt-get; then
    if ! is_executable wget; then
      errcho "wget not available. Please install wget first, then run this script again."
      exit 1
    fi
    wget -qO- https://deb.nodesource.com/setup_6.x | sudo bash - # Adds NodeSource repository to dpkg
    sudo apt-get install -y nodejs git
  elif is_executable yum; then
    if ! is_executable curl; then
      errcho "curl not available. Please install curl first, then run this script again."
      exit 1
    fi
    curl -sL https://rpm.nodesource.com/setup_6.x | bash - # Adds NodeSource repository to yum
    sudo yum install -y nodejs git
  elif is_executable emerge; then
    emerge nodejs git
  elif is_executable pacman; then
    pacman -S nodejs npm git
  else
    errcho "Couldn't determine OS. Please install NodeJS manually, then run this script again."
    errcho "Visit https://github.com/joyent/node/wiki/installing-node.js-via-package-manager for instructions on how to install NodeJS on your OS."
    exit 1
  fi
fi

is_executable python2 && PYTHON='python2'
maybe_sudo="$([ -w "$(npm get prefix)/lib/node_modules" ] || echo 'sudo')"
$maybe_sudo npm install -g slap@latest
{'fraction_non_alphanumeric': 0.09293193717277487, 'fraction_numerical': 0.006544502617801047, 'mean_word_length': 3.1762295081967213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4059891', 'n_tokens_mistral': 1024, 'n_tokens_neox': 970, 'n_words': 362}