yeoman-environment 7.1.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/store.d.ts CHANGED
@@ -28,6 +28,8 @@ export type StoreLookupGeneratorMeta = FoundGenerator & ((StoreGeneratorMeta & {
28
28
  * any, or the one passed to the store method that returned the meta.
29
29
  */
30
30
  export type StoreGeneratorMeta = Omit<GeneratorMeta, 'importGenerator' | 'instantiate' | 'instantiateHelp'> & {
31
+ /** Require the module `require(meta.resolved)`, throws if the module cannot be required synchronously. */
32
+ requireModule?: () => unknown;
31
33
  importGenerator: <G extends BaseGenerator = BaseGenerator>(options?: StoreEnvironmentOptions) => Promise<GetGeneratorConstructor<G> & BaseGeneratorConstructorMeta> | (GetGeneratorConstructor<G> & BaseGeneratorConstructorMeta);
32
34
  instantiate: <G extends BaseGenerator = BaseGenerator>(arguments_?: string[], options?: any, environmentOptions?: StoreEnvironmentOptions) => Promise<G>;
33
35
  instantiateHelp: <G extends BaseGenerator = BaseGenerator>(options?: StoreEnvironmentOptions) => Promise<G>;
package/dist/store.js CHANGED
@@ -67,14 +67,16 @@ export default class Store {
67
67
  if (meta.packagePath) {
68
68
  meta.packagePath = join(meta.packagePath);
69
69
  }
70
+ let requireModule;
70
71
  let importModule;
71
72
  if (!Generator) {
72
73
  if (!meta.resolved) {
73
74
  throw new Error(`Generator Stub or resolved path is required for ${meta.namespace}`);
74
75
  }
76
+ requireModule = () => require(meta.resolved);
75
77
  importModule = () => {
76
78
  try {
77
- return require(meta.resolved);
79
+ return requireModule();
78
80
  }
79
81
  catch (error) {
80
82
  if (error.code === 'ERR_REQUIRE_ESM' || error.code === 'ERR_REQUIRE_ASYNC_MODULE') {
@@ -155,6 +157,7 @@ export default class Store {
155
157
  generatorMeta = {
156
158
  ...meta,
157
159
  importGenerator,
160
+ requireModule,
158
161
  importModule,
159
162
  instantiate,
160
163
  instantiateHelp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeoman-environment",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
5
5
  "keywords": [
6
6
  "development",