1#!/usr/bin/env bash 2 3# Copyright JS Foundation and other contributors, http://js.foundation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17if [[ "$#" -gt 2 || "$#" -lt 1 ]]; then 18 echo "Usage: $0 input [output]" 19 echo "* input: name of input directory/file" 20 echo "* output: name of output directory/file (same as input if not given)" 21 exit 1 22fi 23 24if [[ ! -d $1 && ! -f $1 ]]; then 25 echo "Error: $1 is not a file or directory" 26 exit 1 27fi 28 29FLAG='--out-file' 30if [[ -d $1 ]]; then 31 FLAG='--out-dir' 32fi 33 34if [[ "$#" -eq 1 ]]; then 35 ./node_modules/.bin/babel $1 $FLAG $1 --verbose 36else 37 ./node_modules/.bin/babel $1 $FLAG $2 --verbose 38fi 39