<commit_before>#!/usr/bin/env bash

# Setup Node and install global packages
# Requires: n
debug=${1:-false}

# Load help lib if not already loaded.
if [ -z ${libloaded+x} ]; then
  source ./lib.sh
fi;

# Check if n is installed.
if hash n 2>/dev/null; then
  botintro "Installing latest and LTS versions of Node."

  # Install latest distro.
  n latest;

  # Install LTS distro.
  n lts;

  action "Updating npm."
  # Update npm for LTS.
  npm install npm -g;

  # Declare array of Node directories.
  declare -a createnodedirarray=(
    "$HOME/.node-global-modules"
  )

  action "Creating Node directories"
  # make Node dirs
  make_directories ${createnodedirarray[@]}

  if $dirsuccess; then
    success "Node directories created."
  else
    error "Errors when creating Node directories, please check and resolve."
    cancelled "\e[1mCannot proceed. Exit.\e[0m"
    exit -1
  fi;

  action "Installing Node global packages."
  # Install global Node packages.
  npm install --global create-react-app
  npm install --global caniuse-cmd
  npm install --global doctoc
  npm install --global git-open
  npm install --global git-recent
  npm install --global gulp-cli
  npm install --global gzip-size-cli
  npm install --global http-server
  npm install --global imageoptim-cli
  npm install --global imgur-uploader-cli
  npm install --global is-up-cli
  npm install --global lighthouse
  npm install --global moro
  npm install --global npm-check
  npm install --global npm-home
  npm install --global npm-name-cli
  npm install --global pageres-cli
  npm install --global prettier
  npm install --global remote-share-cli
  npm install --global serve
  npm install --global source-map-explorer
  npm install --global speed-test
  npm install --global stylelint
  npm install --global surge
  npm install --global svgo
  npm install --global trash-cli
  npm install --global viewport-list-cli
  npm install --global vtop

  # fin.
else
  echo "WARNING: n not found.";
fi;<commit_msg>chore: convert package install to loop<commit_after>#!/usr/bin/env bash

# Setup Node and install global packages
# Requires: n
debug=${1:-false}

# Load help lib if not already loaded.
if [ -z ${libloaded+x} ]; then
  source ./lib.sh
fi;

# Check if n is installed.
if hash n 2>/dev/null; then
  botintro "Installing latest and LTS versions of Node."

  # Install latest distro.
  n latest;

  # Install LTS distro.
  n lts;

  action "Updating npm."
  # Update npm for LTS.
  npm install npm -g;

  # Declare array of Node directories.
  declare -a createnodedirarray=(
    "$HOME/.node-global-modules"
  )

  action "Creating Node directories"
  # make Node dirs
  make_directories ${createnodedirarray[@]}

  if $dirsuccess; then
    success "Node directories created."
  else
    error "Errors when creating Node directories, please check and resolve."
    cancelled "\e[1mCannot proceed. Exit.\e[0m"
    exit -1
  fi;

  packages=(
    create-react-app
    caniuse-cmd
    doctoc
    git-open
    git-recent
    gulp-cli
    gzip-size-cli
    http-server
    imageoptim-cli
    imgur-uploader-cli
    is-up-cli
    lighthouse
    moro
    npm-check
    npm-home
    npm-name-cli
    pageres-cli
    prettier
    remote-share-cli
    serve
    source-map-explorer
    speed-test
    stylelint
    surge
    svgo
    trash-cli
    viewport-list-cli
    vtop
  )

  action "Installing Node global packages."
  # Install global Node packages.
  for package in ${packages[@]}; do
    npm install --global $package
  done

  # fin.
else
  echo "WARNING: n not found.";
fi;
{'fraction_non_alphanumeric': 0.09505061867266591, 'fraction_numerical': 0.00281214848143982, 'mean_word_length': 2.764021164021164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '451753', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1112, 'n_words': 403}