-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharc
executable file
·64 lines (49 loc) · 1.79 KB
/
arc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Check if the src directory exists
if [ ! -d "src" ]; then
echo
echo -e " \033[31mMake sure you're in the root directory of your project\033[0m"
echo " Not found src folder"
echo "Becareful to use, it's on beta version, please consider contribution"
exit 0
fi
# path for component
root_dir="src/components"
# not found the comp_dironents direcoty
if [ ! -d "src/components" ]; then
# Create Component directy
mkdir $root_dir
echo -e "\033[32m[OK]\033[0m - components directory created!"
fi
# get the second parament
# name of component to be created
new_component_name=$1
# checking if the directory already
# doesn't exist
if [ ! -d $new_component_name ]; then
# path of the component which is about to create
make_new_dir="$root_dir/${new_component_name}"
# if the component already exists, stop overwriting
if [ -d $make_new_dir ]; then
echo -e "\033[31m[OK]\033[0m - component/${new_component_name} already exits!"
exit 0
fi
mkdir $make_new_dir
echo -e "\033[32m[OK]\033[0m - component/${new_component_name} created!"
# create .tsx file with the same same as parameter as file
get_last_name=$(echo $make_new_dir | awk -F '/' '{print $NF}')
# create files
touch "$make_new_dir/${get_last_name}.tsx"
touch "$make_new_dir/${get_last_name}.scss"
echo -e "
import * as React from \"react\"
import { useState } from \"react\"
import \"${get_last_name}.scss\"
interface Props {}
export const ${get_last_name}: React.FC<Props> = ({}) => {
const [state, setState] = useState<boolean | undefined>(undefined)
return <h1> ${get_last_name} Component </h1>
} " >"$make_new_dir/${get_last_name}.tsx"
# generate log
echo -e "\033[32m[OK]\033[0m - $make_new_dir/${get_last_name} file created!"
fi