Last active
May 23, 2016 07:48
-
-
Save pl12133/ef55fb50ee177acc54e47f710c21bb4d to your computer and use it in GitHub Desktop.
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 | |
function mkcomponent { | |
if [ ! -z "${1}" ] | |
then | |
if [[ $PWD == *"src" ]] | |
then | |
if [ ! -d "./components/${1}" ] | |
then | |
echo 'Making Component' ${1} | |
mkdir ./components/${1} | |
mkdir ./components/${1}/styles | |
cat << EOOF > ./components/${1}/index.js | |
/* eslint-disable no-unused-vars*/ | |
import React, { Component, PropTypes } from 'react'; | |
/* eslint-enable no-unused-vars*/ | |
import styles from './styles/'; | |
const REPLACEME = () => ( | |
<div className={styles}> | |
</div> | |
); | |
REPLACEME.propTypes = { | |
}; | |
export default REPLACEME; | |
EOOF | |
cat << EOOF > ./components/${1}/styles/index.js | |
export default require('./styles.scss').styles; | |
EOOF | |
cat << EOOF > ./components/${1}/styles/styles.scss | |
/* Filename Styles */ | |
:local(.styles) { | |
} | |
EOOF | |
else | |
echo "Component ${1} already exists." | |
fi | |
else | |
echo "Must be in the project src/ directory to mkcomponent" | |
fi | |
else | |
echo "Usage: ${0} ComponentName" | |
echo "Use this script from your projects src/ directory" | |
fi | |
} | |
mkcomponent $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment