Bug 921417 - rewrite build/variant.py in javascript