Skip to content

Instantly share code, notes, and snippets.

@jsakas
Created January 23, 2019 04:29
Show Gist options
  • Save jsakas/d0251185b16be5b4df45084855c61c39 to your computer and use it in GitHub Desktop.
Save jsakas/d0251185b16be5b4df45084855c61c39 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Convert a directory of coffeescript test files to commonjs / jest
# and move them over to the src directory.
#
for coffee_file in $(find tests -name "*.coffee" -type f)
do
js_file=$coffee_file
js_file=$(echo "$js_file" | sed 's/Tests.coffee/.test.js/')
js_file=$(echo "$js_file" | sed 's/Tests.coffee/.test.js/')
js_file=$(echo "$js_file" | sed 's/.coffee/.test.js/')
js_file=$(echo "$js_file" | sed 's/tests/src/')
echo "${coffee_file} -> ${js_file}"
git mv $coffee_file $js_file
coffee -b -c $js_file
babel $js_file -o $js_file --plugins=babel-plugin-transform-amd-to-commonjs
done
jest-codemods src/musicstore --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment