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
[WIP] Support for the --save and --save-dev flags #41
Conversation
looks good, what's missing from this one? |
packageJson[saveType] = packageJson[saveType] || {} | ||
installedPackages.forEach(function (dependency) { | ||
// Assumes package name of in the format of "package-name@x.x.x" | ||
// TODO: Support other install sources (Github, scoped pkgs etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use require('npm-package-arg')
here... it figures that out exactly for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, the npm behavior is to do:
npm install --save rimraf
and it'll pick up rimraf@^2.5.1
for you based on what it resolves. Might simply need to make installMultiple()
throw data of the top-level packages it installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a neater way to do this is to make installMultiple()
work like this:
installMultiple(...)
.then(packages => {
// sift through `packages` for ones that match `cli.input`, and save those
})
to do this, install()
should simply resolve to the necessary package data at the end:
function install (...) {
// these stuff are already available in `install()`.
var pkg = {
name: 'lodash',
fulldata: /* package.json here */,
...
}
return /* snip */
.then(_ => pkg) // <-- resolve the Promise to that stuff so that it can be picked up later
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're correct. Have a better grasp of what I'm trying to do now. I'll pick this up tomorrow, I have to head out the door now.
I think all that's missing is support for other install types:
|
oh, this has merge conflicts... but i rebased your branch for you (pr-41-rebased). You can pick it up like so: git remote add upstream https://github.com/rstacruz/pnpm.git
git fetch upstream master
git reset --hard upstream/pr-41-rebased |
by the way, huge thanks! really appreciate the help. |
Hey @rstacruz, could you take another look at this now. By the way, tests will break if the |
neat! resting now but ill look at this tomorrow. btw, how's the code base so far? did you have trouble finding your way through? |
everything looks ok so far, havent tested it though. |
@rstacruz, yeah codebase is very good, didn't take me too long to ramp up. Makes sense to limit the scope to Would be good to get some CI performance benchmarks in there to make sure that we're keeping track of performance as the codebase evolves. |
good point, maybe --global can just be a passthru to vanilla |
Yeah, unless there's a simple way to do it that is 100% compatible with npm then I'd drop it. Day-to-day I don't do a whole lot of |
I'm also planning to reimplement whatever in |
ah hell, merging this now and trusting CI, haha. thanks for your help! |
[WIP] Support for the --save and --save-dev flags
Woah, hold up, I just noticed that I overwrote some existing tests with this pr :) |
Oops! |
I guess we can manually add them back in. I think what happened is that I was editing the file in my text editor when I updated to your rebased branch. |
btw, |
@@ -0,0 +1,14 @@ | |||
var thenify = require('thenify') | |||
var fs = require('fs') | |||
var writeFile = thenify(fs.writeFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or:
require('mz/fs').writeFile
Yup. One other thing that I noticed, For example |
oh we definitely don't want to do that. using |
Do you want me to fix this pr, add the overwritten tests and squash it or will I let you fix it? |
a new pr would probably be better. |
ok |
Just doing an early pr so you can take a look and let me know if I'm on the correct path or if you have other ideas about how it should be implemented.