Last active
September 18, 2023 19:28
-
-
Save putsan/b63375b58c91a1ae6310e327ad5ef428 to your computer and use it in GitHub Desktop.
Швидке стоворення компонентів реакт у каталозі components
This file contains 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
# Вставляємо це все діло в файл .bashrc , де його шукати читаємо тут: https://cutt.ly/sh2OTHv | |
# Command to open file for editing in Linux: nano ~/.bashrc | |
alias cc=' | |
f(){ | |
compName=$1 | |
# Check if directory exists | |
if [ -d "./src/components/$compName" ]; then | |
echo "Component $compName already exists!"; | |
return 1; | |
fi | |
mkdir ./src/components/$compName; | |
cd ./src/components/$compName; | |
touch $compName.js $compName.scss $compName.test.js index.js; | |
echo -e "import React from \x27react\x27; | |
import \x27./$compName.scss\x27; | |
export const $compName = () => { | |
return ( | |
<>$compName</> | |
) | |
}; | |
" >> $compName.js; | |
echo "//Write styles here" >> $compName.scss; | |
echo -e "import { render } from \x27@testing-library/react\x27; | |
import { $compName } from \x27./$compName\x27; | |
test(\x27renders $compName component\x27, () => { | |
render(<$compName />); | |
}); | |
" >> $compName.test.js; | |
echo -e "export * from \x27./$compName\x27;" >> index.js; | |
cd ../../; | |
echo "Component $compName was created :)"; | |
unset -f f; | |
}; f' |
This file contains 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
# Вставляємо це все діло в файл .bashrc , де його шукати читаємо тут: https://cutt.ly/sh2OTHv | |
# Command to open file for editing in Linux: nano ~/.bashrc | |
alias ccp=' | |
f(){ mkdir ./src/components/$@; | |
cd ./src/components/$@; | |
touch $@.js $@.scss index.js; | |
echo -e "import React from \x27react\x27; | |
import PropTypes from \x27prop-types\x27; | |
import \x27./$@.scss\x27; | |
export const $@ = () => { | |
return ( | |
<>$@</> | |
) | |
}; | |
$@.propTypes = { | |
propName: PropTypes.string, | |
}; | |
" >> $@.js; | |
echo "//Write styles here" >> $@.scss; | |
echo -e "export * from \x27./$@\x27;" >> index.js; | |
cd ../../../; | |
echo "Component $@ was created :)"; | |
unset -f f; }; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment