#!/bin/bash

DMG_FILE="$1"

if [[ $1 == "" ]]; then
	echo "Failed, missing DMG_NAME"
	echo ""
	echo "Usage: cutbox_make_dmg DMG_NAME"
	echo ""
	exit 1
fi

if [[ -x $(npm exec which appdmg) ]]; then
  echo "[✓] appdmg ok"
else
  echo "Failed, missing dependency"
  echo "node-appdmg required."
  echo "visit: https://github.com/LinusU/node-appdmg"
  exit 1
fi

bin_folder=$(dirname $0)

echo "Making new DMG ${DMG_FILE}"

npm exec which appdmg # debug
npm exec appdmg "${bin_folder}/cutbox_appdmg.json" "${DMG_FILE}"
