
# # # ::获取所有文件名
# # echo `> 1.txt`;
# # echo `ls *.tsx >> 1.txt`;
# # echo ls *.tsx >> 1.txt

# # setlocal EnableDelayedExpansion
# # for /f "delims=" %%i in (1.txt) 

# # set var=%%i
# # set var=!var:.tsx=""!
# # echo !var!>>2.txt

# :> 1.txt
# :> 2.txt
# :> 3.txt
# :> index.ts
# ls *.tsx >>1.txt

# # https://www.pcoic.com/system/linux/437.html
# # temp=$(cat ./1.txt)
# # # 替换所有，注意temp后的/数量
# # all=${temp//.tsx/}
# # echo $all >1.txt

# # echo ${string/ab/cd} #将此行的ab替换成cd，含有多个匹配的情况下，只替换一次。
# # echo ${string//ab/cd} #将此行的ab替换成cd，双斜杠替换所有匹配。
# # echo ${string/#abc/bb} #将以abc开头的替换成bb，和^有点像。


# for line in `cat  1.txt`
# do
#     # echo $line∂
#     echo  "${line//.tsx/}" >> 2.txt
# done

# # # ::输出导出格式到txt文件
# for line in `cat 2.txt`
# do
#     echo $line
#     echo "import $line from \"./$line\""  >>3.txt
# done


# # echo `wc -l 3.txt`


# # # while read line
# # # do
# # #     echo $line
# # # done < 2.txt

# # # ::生成index.ts 文件并且导入包
# # # for line in `cat  2.txt`
# while read line
# do
#     echo $line
#     echo "$line;" >>index.ts
# done < 3.txt

# # # # ::修改index.ts 文件并且导包
# echo "export {" >>index.ts

# for line in `cat  2.txt`
# do
#     echo "$line,"  >>index.ts
# done

# echo "}" >>index.ts

# rm -rf *.txt

# 更新组件目录导入

:> 1.txt
:> 2.txt
:> 3.txt
:> 4.txt
:> index.ts

function ergodic(){
  for file in `ls $1`
  do
    if [ -d $1"/"$file ]
    then
      ergodic $1"/"$file
    elif [ "${file##*.}"x = "tsx"x ]
    # else  if [ "${file##*.}"x = "zip"x ]||[ "${file##*.}"x = "gz"x ]
    then
        #如果符合条件将文件放入集合中
        local path=$1"/"$file 
        local name=$file
        # echo $file
        #   local size=`du --max-depth=1 $path|awk '{print $1}'` 
        echo $path >> 1.txt
        echo $name >> 2.txt
    else
        echo
    fi
  done
}
IFS=$'\n' #这个必须要，否则会在文件名中有空格时出错
INIT_PATH=".";
ergodic $INIT_PATH



for line in `cat  2.txt`
do
    echo  "${line//.tsx/}" >> 3.txt
done


# c=0
# for line in `cat 3.txt`
# do
#   account=$line
#   accounts[$c]=$account
#   ((c++))
# done

# echo $accounts
file1=1.txt
k1=0
while read LINE
do
    list1_x[$k1]=$LINE
    ((k1++))
    # index=`$index + 1`
done < $file1


file2=3.txt
k2=0
while read LINE
do
    list2_x[$k2]=$LINE
    ((k2++))
    # index=`$index + 1`
done < $file2

# exec 3<"3.txt"
# exec 1<"1.txt"
# while read line1<&3 && read line2<&1
# do
#     # local f1=$line1
#     # local f2=$line2
#     # echo f1 
#     echo  $line1
#         # echo "import $line from \"$line2\""  >>4.txt
# done
length=${#list1_x[@]} # 获取列表内数据的个数
for ((i=0; i<${length}; i++));
do
    # echo ${list2_x[$i]} ${list1_x[$i]}
    echo "import ${list2_x[$i]} from \"${list1_x[$i]}\""  >> 4.txt
done


# # while read line
# # do
# #     echo $line
# # done < 2.txt

# # ::生成index.ts 文件并且导入包
# for line in `cat  2.txt`
while read line
do
    echo $line
    s="${line//.tsx/}" 
    echo "$s;" >> index.ts
done < 4.txt


# # # ::修改index.ts 文件并且导包
echo "export {" >>index.ts

for line in `cat  3.txt`
do
    echo "$line,"  >>index.ts
done

echo "}" >>index.ts

rm -rf *.txt



#  then
#       ergodic $1"/"$file
#     else  if [ "${file##*.}"x = "tsx"x ]
#     # else  if [ "${file##*.}"x = "zip"x ]||[ "${file##*.}"x = "gz"x ]
#     then
#         #如果符合条件将文件放入集合中
#         local path=$1"/"$file 
#         #   local name=$file      
#         #   local size=`du --max-depth=1 $path|awk '{print $1}'` 
#         echo $path 
#         echo $path >> 1.txt
#     else