yeoman-test
Version:
Test utilities for Yeoman generators
16 lines (15 loc) • 552 B
JavaScript
/**
* @param {import('@yeoman/types').BaseEnvironmentOptions} options
* @returns {import('@yeoman/types').BaseEnvironment}
*/
export const createEnv = async (options) => {
const DynamicEnv = await import('yeoman-environment');
if (typeof DynamicEnv === 'function') {
return new DynamicEnv(options);
}
if (typeof DynamicEnv.default === 'function') {
// eslint-disable-next-line new-cap
return new DynamicEnv.default(options);
}
throw new Error(`'yeoman-environment' didn't returned a constructor`);
};