Skip to content

Commit

Permalink
Merge 64a01aa into e0a5425
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jan 3, 2020
2 parents e0a5425 + 64a01aa commit b5cae6e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/run-context.js
Expand Up @@ -76,7 +76,10 @@ RunContext.prototype._run = function() {

this.ran = true;
var namespace;
this.env = yeoman.createEnv([], {}, new TestAdapter());
this.env = (this.envCB || (env => env)).call(
this,
yeoman.createEnv([], {}, new TestAdapter())
);

helpers.registerDependencies(this.env, this.dependencies);

Expand Down Expand Up @@ -209,6 +212,20 @@ RunContext.prototype.inTmpDir = function(cb) {
return this.inDir(tmpdir, cb);
};

/**
* Create an environment
*
* This method is called automatically when creating a RunContext. Only use it if you need
* to use the callback.
*
* @param {Function} [cb] - callback who'll receive the folder path as argument
* @return {this} run context instance
*/
RunContext.prototype.withEnvironment = function(cb = env => env) {
this.envCB = cb;
return this;
};

/**
* Clean the directory used for tests inside inDir/inTmpDir
*/
Expand Down

0 comments on commit b5cae6e

Please sign in to comment.