-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to handle save: true
when requested package is already installed
#47
Comments
npm assumes |
The point is, that we never call That being said, I would prefer if we did not have any options to pass to npm. I'm not sure it is feasible though. And I think that this is a separate topic. |
I also think we should just remove this option and use npm's default behavior which automatically saves the dependency to the package.json. Though with limited insight without actually trying to reproduce/test what your seeing, I don't understand what
has to do with the |
I think what Raphael is meaning is that it's "broken" in the following case: # Installs it into node_modules without updating package.json
npm install --no-save cordova-plugin-camera
# This detects that it's already installed in node_modules and
# doesn't invoke npm at all, therefore it's never added to package.json
cordova plugin add cordova-plugin-camera I'm not sure what to do in that particular edge case, aside from maybe documenting it? |
How about something like this? Yes documentation is good like you said, but maybe also include user action feedback? Just would involve a bit of work. Use Case 1
or
I believe
Use Case 2
Only difference between these cases is that I had already provided Cordova plugin configurations in package.json. The feedback message drops about adding missing configs. We can also create the frequent-issues page that would explain a bit more detail on how something like this happens. For example the Lastly, what if a plugin has a Anyways, I understand now the use case. |
After merging #24, we do not invoke
npm install
if the requested package is already installed. Thus,cordova-fetch
will not add the requested package todependencies
ofpackage.json
.However, some tests in
cordova-lib
expect that callingcordova-fetch
with{save: true}
will add the requested package todependencies
ofpackage.json
. This does not cause the tests to fail with the current version ofcordova-fetch
since there are no "dependency cache-hits" right now. But when I experimented with #44 to speed upcordova-lib
E2E tests, some of the tests started to fail.So how should we handle
save: true
when the requested package is already installed?I think the current behavior is fine. When we find a package already installed, either a user manually installed it, or it had been previously installed by Cordova. In any case, it would have been added to
dependencies
unless that behavior was explicitly suppressed. So I don't really expect this behavor to break anything.Frankly, it would be better if
cordova-fetch
would only fetch dependencies and was not expected to managepackage.json
in the first place, but that is a different story I guess.The text was updated successfully, but these errors were encountered: