Skip to content

Instantly share code, notes, and snippets.

@JamieMason
Last active January 10, 2017 15:21
Show Gist options
  • Save JamieMason/52e985b308858b01edb5bc7bace0a22c to your computer and use it in GitHub Desktop.
Save JamieMason/52e985b308858b01edb5bc7bace0a22c to your computer and use it in GitHub Desktop.
Run some useful codemods together in bulk **hard-coded to run against `$pwd/src/app` currently**
#!/bin/bash
function codemods() {
echo "-----"
echo "Running $1 from https://github.com/JamieMason/codemods.git"
jscodeshift -t "${TMPDIR}codemods/transforms/$1.js" "$2"
}
function js_codemod() {
echo "-----"
echo "Running $1 from https://github.com/cpojer/js-codemod.git"
jscodeshift -t "${TMPDIR}js-codemod/transforms/$1.js" "$2"
}
function react_codemod() {
echo "-----"
echo "Running $1 from https://github.com/reactjs/react-codemod.git"
jscodeshift -t "${TMPDIR}react-codemod/transforms/$1.js" "$2"
}
function clone_repo() {
if [ -d "$2" ]; then
echo "$2 is already cloned"
else
echo "Cloning $1 into $2"
git clone "$1" "$2"
fi
}
npm install -g jscodeshift && \
clone_repo https://github.com/JamieMason/codemods.git "${TMPDIR}codemods" && \
clone_repo https://github.com/cpojer/js-codemod.git "${TMPDIR}js-codemod" && \
clone_repo https://github.com/reactjs/react-codemod.git "${TMPDIR}react-codemod" && \
codemods sort-jsx-props src/app && \
codemods sort-object-props src/app && \
js_codemod no-vars src/app && \
js_codemod object-shorthand src/app && \
js_codemod template-literals src/app && \
js_codemod unchain-variables src/app && \
js_codemod unquote-properties src/app && \
react_codemod create-element-to-jsx src/app && \
react_codemod findDOMNode src/app && \
react_codemod sort-comp src/app
@JamieMason
Copy link
Author

JamieMason commented May 9, 2016

Usage

Hard-coded to run against $pwd/src/app currently.

curl -L https://gist.github.com/JamieMason/LONG_HASH/raw/LONG_HASH/codemods.sh | bash

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