Last active
September 30, 2019 07:49
-
-
Save jling90/4b7531f1a1faeb0b71a3a7c655189bed to your computer and use it in GitHub Desktop.
Create react directory
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
# Creates a index.js, {ComponentName}.jsx, styled/{ComponentName}.js at specified path | |
# $1 - Path to create files at | |
# $2 - Component name | |
# Example usage: | |
# crdir "src/components/shared" "Foo" | |
# | |
# src/components/shared | |
# |-- index.js, Foo.jsx | |
# --- styled/ | |
# |--Foo.js | |
# | |
function crdir() { | |
mkdir -p "$1/$2/styled" | |
touch "$1/$2/"{index.js,$2.jsx,styled/$2.js} | |
echo "export { default } from './$2';" >> "$1/$2/index.js" | |
cat << EOF > $1/$2/$2.jsx | |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
const $2 = () => {}; | |
$2.propTypes = { | |
}; | |
export default $2; | |
EOF | |
echo "import styled from 'styled-components';" >> "$1/$2/styled/$2.js" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment