#!/usr/bin/env bash
set -euo pipefail

: "${PAPERCLIP_INSTALL_TEST_LOG:?PAPERCLIP_INSTALL_TEST_LOG is required}"
node --version >"${PAPERCLIP_INSTALL_TEST_LOG}.node"
{
  printf 'NPM_CONFIG_REGISTRY=%s\n' "${NPM_CONFIG_REGISTRY:-}"
  printf 'npm_config_registry=%s\n' "${npm_config_registry:-}"
  printf 'NPM_CONFIG_USERCONFIG=%s\n' "${NPM_CONFIG_USERCONFIG:-}"
  printf 'npm_config_userconfig=%s\n' "${npm_config_userconfig:-}"
  if [ -n "${NPM_CONFIG_USERCONFIG:-}" ] && [ -f "$NPM_CONFIG_USERCONFIG" ]; then
    sed 's/^/npmrc:/' "$NPM_CONFIG_USERCONFIG"
  fi
  printf '%s\n' "$@"
} >>"$PAPERCLIP_INSTALL_TEST_LOG"
