factor out the common helper logic to register a list of dependent generators into an env.
(also change to use _.isArray for array type check)