Skip to content

Commit

Permalink
fixbug: 修改脚本问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Dec 7, 2021
1 parent 055e724 commit bd53673
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions script/template.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/bash

# 脚本文件,运行 npm run ct $NAME 一键创建组件

NAME=$1

# 打印组件目录的完整地址
Expand All @@ -12,20 +14,20 @@ if [ "$#" -ne 1 ] || [[ $NAME =~ $re ]] || [ "$NAME" == "" ]; then
fi

# 拼接组件存放路径
DIRNAME="$FILE_PATH/components/$NAME"
FILENAME="$FILE_PATH/components/$NAME"

# 判断此路径是否有想同的组件
if [ -d "$DIRNAME" ]; then
if [ -d "$FILENAME" ]; then
echo -e "\033[0;31m[ERROR] $NAME 已经存在相同的组件 \033[0m"
exit 1
fi

# 生成组件目录
mkdir -p "$DIRNAME"
mkdir -p "$DIRNAME/src"
mkdir -p "$FILENAME"
mkdir -p "$FILENAME/src"

# 生成文件.vue 并写入模板
cat > $DIRNAME/src/index.vue <<EOF
cat > $FILENAME/src/index.vue <<EOF
<template>
<div>
</div>
Expand All @@ -45,7 +47,7 @@ export default defineComponent({
EOF

# 生成导入模板文件 index.ts
cat <<EOF >"$DIRNAME/index.ts"
cat <<EOF >"$FILENAME/index.ts"
import type { App } from 'vue'
import ${NAME} from './src/index.vue'
// import type { SFCWithInstall } from "../types";
Expand Down

0 comments on commit bd53673

Please sign in to comment.