Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inTmpDir changes original behavior of inDir #722

Closed
blai opened this issue Dec 10, 2014 · 4 comments
Closed

inTmpDir changes original behavior of inDir #722

blai opened this issue Dec 10, 2014 · 4 comments

Comments

@blai
Copy link
Contributor

blai commented Dec 10, 2014

The intention of the second parameter of inDir was discussed/introduced here.

The var release in inTmpDir does not seem to do anything (but I could be wrong). Suggested change here is to change inTmpDir like so

RunContext.prototype.inTmpDir = function (cb) {
  var tmpdir = path.join(os.tmpdir(), crypto.randomBytes(20).toString('hex'));
  return this.inDir(tmpdir, cb);
};

Thoughts?

@SBoudrias
Copy link
Member

That make sense to me. But couldn't you just use .on('ready')?

@blai
Copy link
Contributor Author

blai commented Dec 10, 2014

Not really. Let's say I am trying to preload some files into the target directory so I can run some test for the scenario of running a yeoman generator with existing contents. .on('read') would not tell me what the actual target directory path is (assuming I use inTmpDir so that path is basically random).

blai added a commit to blai/generator that referenced this issue Dec 10, 2014
blai added a commit to blai/generator that referenced this issue Dec 10, 2014
@SBoudrias
Copy link
Member

FWIW, when you're inside the ready event, process.cwd() will be the temp directory as we're in the exact context a generator will be runned.

@blai
Copy link
Contributor Author

blai commented Dec 11, 2014

Ah, good point, I will look into using that, thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants