yeoman-test 9.1.0 → 9.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.
@@ -69,6 +69,7 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
69
69
  private ran;
70
70
  private errored;
71
71
  private readonly beforePrepareCallbacks;
72
+ private environmentRun?;
72
73
  /**
73
74
  * This class provide a run context object to façade the complexity involved in setting
74
75
  * up a generator for testing
@@ -153,6 +154,13 @@ export declare class RunContextBase<GeneratorType extends BaseGenerator = Defaul
153
154
  * @return {this} run context instance
154
155
  */
155
156
  withEnvironment(callback: any): this;
157
+ /**
158
+ * Customize enviroment run method.
159
+ *
160
+ * @param callback
161
+ * @return {this} run context instance
162
+ */
163
+ withEnvironmentRun(callback: (this: this, env: DefaultEnvironmentApi, gen: GeneratorType) => void): this;
156
164
  /**
157
165
  * Run lookup on the environment.
158
166
  *
@@ -46,6 +46,7 @@ export class RunContextBase extends EventEmitter {
46
46
  ran = false;
47
47
  errored = false;
48
48
  beforePrepareCallbacks = [];
49
+ environmentRun;
49
50
  /**
50
51
  * This class provide a run context object to façade the complexity involved in setting
51
52
  * up a generator for testing
@@ -81,7 +82,8 @@ export class RunContextBase extends EventEmitter {
81
82
  await this.build();
82
83
  }
83
84
  try {
84
- await this.env.runGenerator(this.generator);
85
+ const environmentRun = this.environmentRun ?? ((env, generator) => env.runGenerator(generator));
86
+ await environmentRun.call(this, this.env, this.generator);
85
87
  }
86
88
  finally {
87
89
  this.helpers.restorePrompt(this.env);
@@ -215,6 +217,16 @@ export class RunContextBase extends EventEmitter {
215
217
  this.envCB = callback;
216
218
  return this;
217
219
  }
220
+ /**
221
+ * Customize enviroment run method.
222
+ *
223
+ * @param callback
224
+ * @return {this} run context instance
225
+ */
226
+ withEnvironmentRun(callback) {
227
+ this.environmentRun = callback;
228
+ return this;
229
+ }
218
230
  /**
219
231
  * Run lookup on the environment.
220
232
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeoman-test",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "description": "Test utilities for Yeoman generators",
5
5
  "keywords": [
6
6
  "yeoman",