AnalyticalGraphicsInc/cesium — pull request #1707 by kring (2014-05-14 19:24:21+00:00)
Title: Add an ANT target to sort the list of modules in all js files

I got sick of doing this by hand while moving `TerrainProvider` to `Core`, so I wrote a script to do it. It turned out to be a lot more fiddly than I expected, but it works. It would probably be less fiddly if I spent more time on it or if I were better at regular expressions, but you know how it goes. Anyway, here's what it gets right:

* The topmost module is kept in that position for defineSuites that don't specify a spec name explicitly.
* It doesn't break when the module name is different from the function parameter name (e.g. CesiumMath).
* It doesn't break anything, at least not anything that's tested by our unit tests.

And what it gets wrong:

* It bails on the one source file that has a comment embedded in the list of modules (`LinkButton`) because I couldn't be bothered to make it work right.
* It complains about lots of files not having the expected syntax. Some of them don't use AMD, so this is maybe expected. Others use AMD but don't have any dependencies, so it would be nice if it didn't complain for those.
* The regular expression used to parse the list of requires is kind of nuts and can undoubtedly be simplified.