Created
July 13, 2022 03:08
-
-
Save dgaitsgo/611a5318f497b14301824ebfb30af34c to your computer and use it in GitHub Desktop.
New React/CSS Module TS Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$1" == "" ]; then | |
| echo "Missing $component name" | |
| exit 0 | |
| fi | |
| for comp in "$@" | |
| do | |
| if [ ! -d ./$comp ]; then | |
| echo -e "Creating $comp/$comp.tsx" | |
| echo -e "Creating $comp/$comp.module.css" | |
| echo -e "Creating $comp/index.ts" | |
| fi | |
| mkdir $comp | |
| touch $comp/$comp.module.css | |
| touch $comp/$comp.tsx | |
| touch $comp/index.ts | |
| class=$"import styles from './$comp.module.css' | |
| interface "$comp"Props { | |
| } | |
| function $comp({ }: "$comp"Props) { | |
| return () | |
| } | |
| export default $comp" | |
| index=$"export { default } from './$comp'" | |
| echo "$class" > $comp/$comp.tsx | |
| echo "$index" > $comp/index.ts | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this in
/usr/local/bin/next-comp$> next-comp ComponentNameCreating ComponentName/ComponentName.tsxCreating ComponentName/ComponentName.module.cssCreating ComponentName/index.ts