Conversation
|
What kind of bugs did you encounter with npm? Is there something that could potentially be fixed in npm itself? |
|
Mostly this one: https://github.com/isaacs/npm/issues/4202 Thing is,
So, I kept path based lookup, but use NPM to find the global modules path here: https://github.com/yeoman/generator/pull/420/files#diff-49d286273f6324a7d8eb78b2924c40a1R55 - So, it's not the best, but it is already working way better for me! |
|
Hmm, ok. I think we can work around it for now, but would be nice to use npm fully in the future. Would you be able to do a pr on npm for isaacs/npm#4202? Just a thought; Would it make sense for Can we get the npm global root, then set NODE_PATH, then do require.resolve? |
Been there done that, wasn't working :( I tried by doing it like so |
|
As per the meeting: we're happy to move forward with this implementation. Can we rebase and merge? |
|
Let's wait for #383 to be merged in before. |
lib/actions/spawn_command.js
Outdated
|
Lgtm, but would still like to see some simple perf comparison pre/post of this. |
|
Before this fix, we had 68.54965612209382 ops/sec Now merely 0.9368288955108388... |
|
I've been searching for other way to get global module root without requiring to spawn a command, and this is quite hard. I tried using NPM from node, but that won't work as the global NPM create files in its modules that won't be read by any local NPM (and you can't require the global NPM modules if NODE_PATH isn't setup - and it isn't by default). I really start to feel like we'll need to stick to guessing paths... Maybe we could check with Any other ideas? |
Let's go ahead with this approach for now. Could you revise your PR to reflect this, @SBoudrias? :) |
|
Reverting the use of spawned Before this fix, we had 68 ops/sec With and without |
|
Woo! |
|
Had to fight Travis execution order to export a NODE_PATH to allow unit test to run on top the new logic. Finally got it! BTW, previous benchmark assertion where wronged, I updated previous comment correctly. So we're losing a bit in performance, but way less than before. |
lib/env/index.js
Outdated
|
@sindresorhus Could you check and give a run to the sync version? For some reason I lost about 3ms in the benchmark, which is pretty weird considering... |
|
This is really strange. Looks like the sync one is considerably faster. I guess the perf issues are not in those codepaths. Sync: Env#lookup 800.5611439952063 Btw, I ran the tests on this PR and one failed: |
|
@sindresorhus That is possible as you're not running the tests from the global npm Can you give me where your npm modules are installed? (You can also try running the test suite setting up BTW, this fails now because there was no test coverage on the lookup method before this PR. (so it is probably not a bug with the current implementation) |
|
~/dev/generator/node_modules |
|
Yeah, that's it. As it is not a standard global module folder, the system miss it when it tries to guess the location of the global module folder. |
|
Right. Hmm, can you just ignore the test when the test env var is set? https://github.com/yeoman/yo/blob/master/cli.js#L122 |
|
There, it skip if it is not defined. |
|
Coverage increased (+2.01%) when pulling db12d3aa13de66b164f80a1eea342b98ca0c6835 on SBoudrias:improve-lookup into f049269 on yeoman:master. |
|
Ok, reverted to the sync version. FWIW, I ran the benchmark on my mac, and I got 738 ops/sec for the new version, and 120 ops/sec for the old version. (and 443 ops/sec for the async version) Previously I had only runned those benchmark on my Windows box. I guess it was hitting some OS specific bottleneck (probably file/directory reading)... Soooooooooo I guess we're OK performance wise. @sindresorhus mind to run benchmark ( |
|
(btw, you likely already know this but this PR will need to be rebased before we can merge :) 740 o/s on new version. |
|
@SBoudrias Env#lookup 802.8510136462345, feel free to merge when you fixed the merge conflict and squashed ;) |
The main point is to allow passing other `std` Streams to output command content
Allow #usage and #help tests to be independent from each other
Also remove a lot of noisy "too much configs" code that growed the complexity of the code paths.
|
Fixed |
Exactly what I wanted :) |
|
@SBoudrias this is really good! Thanks so much for your hard cleaning up the generator system :) |

Trimmed down version of #395 still relying on manual paths declaration after encountering too many bugs with NPM to allow using it in lieu of paths lookups.