1425bb815Sopenharmony_ci#!/usr/bin/env bash 2425bb815Sopenharmony_ci 3425bb815Sopenharmony_ci# Copyright JS Foundation and other contributors, http://js.foundation 4425bb815Sopenharmony_ci# 5425bb815Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 6425bb815Sopenharmony_ci# you may not use this file except in compliance with the License. 7425bb815Sopenharmony_ci# You may obtain a copy of the License at 8425bb815Sopenharmony_ci# 9425bb815Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10425bb815Sopenharmony_ci# 11425bb815Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12425bb815Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS 13425bb815Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14425bb815Sopenharmony_ci# See the License for the specific language governing permissions and 15425bb815Sopenharmony_ci# limitations under the License. 16425bb815Sopenharmony_ci 17425bb815Sopenharmony_ciif [[ "$#" -gt 2 || "$#" -lt 1 ]]; then 18425bb815Sopenharmony_ci echo "Usage: $0 input [output]" 19425bb815Sopenharmony_ci echo "* input: name of input directory/file" 20425bb815Sopenharmony_ci echo "* output: name of output directory/file (same as input if not given)" 21425bb815Sopenharmony_ci exit 1 22425bb815Sopenharmony_cifi 23425bb815Sopenharmony_ci 24425bb815Sopenharmony_ciif [[ ! -d $1 && ! -f $1 ]]; then 25425bb815Sopenharmony_ci echo "Error: $1 is not a file or directory" 26425bb815Sopenharmony_ci exit 1 27425bb815Sopenharmony_cifi 28425bb815Sopenharmony_ci 29425bb815Sopenharmony_ciFLAG='--out-file' 30425bb815Sopenharmony_ciif [[ -d $1 ]]; then 31425bb815Sopenharmony_ci FLAG='--out-dir' 32425bb815Sopenharmony_cifi 33425bb815Sopenharmony_ci 34425bb815Sopenharmony_ciif [[ "$#" -eq 1 ]]; then 35425bb815Sopenharmony_ci ./node_modules/.bin/babel $1 $FLAG $1 --verbose 36425bb815Sopenharmony_cielse 37425bb815Sopenharmony_ci ./node_modules/.bin/babel $1 $FLAG $2 --verbose 38425bb815Sopenharmony_cifi 39