prezbuilder 609 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash
set -e

usage() {
  echo "Usage: $0 dev|build [src_dir [output_dir]]" >&2
  exit 1
}

checkdir() {
  if [[ -z $1 ]]; then
    echo ""
    return 0
  fi
14
  local DIR=`readlink -f $1`
15
  if [[ ! -d "$DIR" ]]; then
16
    echo "$DIR does not exist or is not a directory" >&2
17
18
19
20
21
22
23
24
    usage
  fi
  echo "$DIR"
  return 0
}

case "$1" in
  dev|build) COMMAND="$1" ;;
25
26
27
28
  *)
      echo "unknown command: '$1'" >&2
      usage
    ;;
29
30
esac

31
32
export SRC=`checkdir ${2:-src}`
export OUTPUT=`checkdir ${3:-public}`
33

34
BASE=`dirname $(readlink -f $0)`/..
35
exec "$BASE/node_modules/.bin/gulp" --cwd "$BASE" "$COMMAND"