do not merge - publish.js review

please use spaces after `if` and `for` and use curly braces for statements which take more than one line. (at some point we'll also properly wrap all one-liners).