Skip to content

Instantly share code, notes, and snippets.

@ggarek
Last active August 28, 2015 21:10
Show Gist options
  • Save ggarek/d313cd2ab18f9fca31a8 to your computer and use it in GitHub Desktop.
Save ggarek/d313cd2ab18f9fca31a8 to your computer and use it in GitHub Desktop.
Shell scarpbook

I had a task to convert a project which was written using AMD and partially in ES6 (new code).

This gist describes my approach in details.

###Prerequisites The codebase is written in AMD and paritally in ES6. All AMD modules have simple .js extension, whereas all ES6 modules have .es6.js extension.

###Used tools

###Lets go

So, we have N .js files total. M of them are written in ES6 and have extension .es6.js. The rest N-M are written in AMD.

Number of all .js files

find -type f -name "*.js" | wc -l

Number of all ES6 files

find -type f -name "*.js" | grep "es6" | wc -l

Number of all AMD files

find -type f -name "*.js" | grep -v "es6" | wc -l

Step 1. Convert all AMD files to ES6

Convert AMD file to ES6

amdtoes6 $file > $dest

Beautify file

js-beautify -f $dest -r -s 2 -c " " -n

Rename output as original file

mv MOVE $f

Composed command

find -type f -name "*.js" | grep -v "es6" | while read f; do amdtoes6 $f > MOVE && js-beautify -f MOVE -r -s 2 -c " " -n && mv MOVE $f; done

Step 2. Rename all .es6.js to .js

find -type f -name "*.js" | grep "es6" | while read f; do git mv $f `echo $f | sed s/.es6//`; done

Remove all merged branches containing 'feature' in the title

git branch --merged | grep 'feature' | xargs -n 1 git branch -d

List all local branches which contain specified commit (SO)

git branch --contains <commit>

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