just for information, we have the same thing in https://github.com/mozilla-b2g/gaia/blob/master/build/utils.js#L31-L62 ;) the nice thing is that it's a CommonJS module so it can probably be reused here if necessary