Skip to content

Instantly share code, notes, and snippets.

@zacharyabresch
Last active April 4, 2018 14:17
Show Gist options
  • Save zacharyabresch/93ea97f74d5e53485ff25dd2b07116cc to your computer and use it in GitHub Desktop.
Save zacharyabresch/93ea97f74d5e53485ff25dd2b07116cc to your computer and use it in GitHub Desktop.
A one-line terminal command for JS projects. Includes `webpack`, `babel`, `jest`, `eslint`. Great for scratch coding, katas, proof of concepts, etc.
#!/bin/bash
yarn init -y && yarn add --dev babel-core webpack webpack-cli jest-cli babel-jest babel-loader prettier pretty-quick husky babel-preset-env babel-preset-react eslint eslint-config-prettier eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react && echo '{ "presets": ["env", "react"] }' >> .babelrc && echo 'module.exports = { env: { jest: true }, extends: ["airbnb", "prettier"] };' >> .eslintrc.js && mkdir src && touch src/index.test.js src/index.js && touch README.md && sed -ie -E 's/("license": ".*",)/\1"scripts": { "start": "webpack --mode development", "test": "jest --watchAll" },/g' ./package.json && ./node_modules/.bin/prettier --write ./package.json && subl -an .
@zacharyabresch
Copy link
Author

Replace subl -an . with your editor's command for opening a directory.

@zacharyabresch
Copy link
Author

Using this as a terminal command:

  • Download the source code and put it somewhere (i.e. ~/scripts/newj.sh)
  • Make it exectuable: chmod u+x ~/scripts/newj.sh
  • Run it where you want to initialize your project: cd cool-project/ && ~/scripts/newj.sh
  • Pro tip: Add this line to your .bash_profile and get a new CLI tool!
    • alias newj='~/scripts/newj.sh' then just use newj where ever, whenever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment