Skip to content

Instantly share code, notes, and snippets.

@stefan-vatov
Forked from JamieMason/codemods.sh
Created January 10, 2017 15:21
Show Gist options
  • Save stefan-vatov/9648ed7aad0d014c8b646e2e619e0da9 to your computer and use it in GitHub Desktop.
Save stefan-vatov/9648ed7aad0d014c8b646e2e619e0da9 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment