Skip to content

Instantly share code, notes, and snippets.

@niradler
Created April 29, 2019 09:56
Show Gist options
  • Save niradler/c57a244677c4e402253dc84b8ef3b560 to your computer and use it in GitHub Desktop.
Save niradler/c57a244677c4e402253dc84b8ef3b560 to your computer and use it in GitHub Desktop.
Make Your Own React CLI with Bash
# ~/code_templates/component.js
import React from 'react';
import './COMPONENT_NAME.scss';
function COMPONENT_NAME() {
return <div>Hello</div>;
}
export default COMPONENT_NAME;
# make_component.sh
mkdir -p src/components/$1
touch src/components/$1/$1.scss
sed -e "s/COMPONENT_NAME/$1/g" ~/code_templates/component.js > src/components/$1/index.js
#usage
./make_component.sh Button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment