#!/usr/bin/env bash

function throw() {
	# Modify from `studio.sh` in Android Studio
	local _title;
	_title='Git commit failed!';
	if [[ -n "`which zenity`" ]]; then         zenity --error --title="$_title" --text="$1";
	elif [[ -n "`which kdialog`" ]]; then      kdialog --error "$1" --title "$_title";
	elif [[ -n "`which xmessage`" ]]; then     xmessage -center "ERROR: $_title: $1";
	elif [[ -n "`which notify-send`" ]]; then  notify-send "ERROR: $_title: $1";
	else  echo "ERROR: $_title\n$1";  fi
	exit 1;
}

# apply original syntaxes
bash ./syntaxes/apply_original &&
	npm run test -s -- --reporter=list || throw "npm test exit without 0";
