Home Ask Login Register

Developers Planet

Your answer is one click away!

Vladimir Starkov February 2016

change dir to newly created yeoman project from yeoman generator itself

I want to scaffold a project into same named directory and after generator finished with its job i want consumer to be redirected to that folder.

So I'm accepting project name as an argument: this.argument('name', { type: String, required: false }); and then create that folder and change destinationRoot to it:

if (this.name) {

After all I want to make kinda cd this.name at the end stage of runContext cycle. I tried to change destinationRoot to parent directory and then cd to to it, and it supposed to work, but it doesn't:

end: function () {
  if (this.name) {
    console.log('BEFORE', ls('.'))
    console.log('AFTER', ls('.'))

Here is log:

BEFORE [ 'README.md', 'index.js', 'package.json', 'test.js' ]
AFTER [ 'meow' ]

But It doesn't work because once yeoman finish it's job I’m still in the currrent folder and not in the meow folder. Does anybody know how to fix that?


Simon Boudrias February 2016

Yeoman doesn't change directory for the user.

You might be able to do it manually by using process.chdir()

Post Status

Asked in February 2016
Viewed 3,125 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life