chiubaka / generator-chiubaka-typescript-package

Yeoman generator for standard Chiubaka Technologies TypeScript packages for libraries and other such things.
1 stars 0 forks source link

Generator `start` command is running commands in cwd instead of destinationRoot #132

Closed chiubaka closed 2 years ago

chiubaka commented 2 years ago

Not sure when this started, but noticed while playing with #45. It correctly writes a bunch of the files to /tmp/generated, but then tries to run things like lint:fix in the current working directory.

Maybe this is because of #124? Perhaps this is one of the things the internal function was doing... damnit.

chiubaka commented 2 years ago

Yeah, git bisect agrees with my assessment :(((

chiubaka commented 2 years ago

Here's the library that yeoman is using internally for spawnCommand and spawnCommandSync: https://github.com/sindresorhus/execa

And here's the code for those two commands: https://github.com/yeoman/generator/blob/357932222b7806e6d3e60c44d5cbdd9b2da74dcf/lib/actions/spawn-command.js

chiubaka commented 2 years ago

Honestly, though, the weirder thing is the way destinationRoot is undefined in all the generators?? Something happened that's squashing that value. If that value were still around, I could just pass it to exec and everything would work normally.

chiubaka commented 2 years ago

Alright, destinationRoot being undefined is intentional. That happens here: https://github.com/yeoman/generator/blob/main/lib/index.js#L201-L202

chiubaka commented 2 years ago

Ok, figured out that destinationRoot() the method is what I should be using. It's now easy to pass cwd to the exec command, and things work as normal.

One catch: exec is nice in a lot of ways because it gives me stdout and stderr as strings after execution. However, this does mean that I'm no longer able to see what's happening as the generator does its work, so it feels like the generator is just stalling for awhile.

This makes #98 a bit more urgent.

chiubaka commented 2 years ago

Also, need to come up with a regression test for this bug, since it was pretty nasty...