Skip to content
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

Wrong platform version is detected when dependencies and devDependencies are both present #866

Closed
3 tasks done
zoltan-mihalyi opened this issue Jan 5, 2021 · 1 comment · Fixed by #874
Closed
3 tasks done

Comments

@zoltan-mihalyi
Copy link

Bug Report

Problem

When dependencies and devDependencies are both present, running cordova prepare installs the wrong platform version.

What is expected to happen?

Using cordova-fetch for cordova-electron@2.0.0 is printed

What does actually happen?

Using cordova-fetch for cordova-electron@1.0.0 is printed

Information

Environment, Platform, Device

the relevant part of my package.json:

{
  "devDependencies": {
    "cordova-electron": "2.0.0"
  },
  "dependencies": {
    "cordova-plugin-googleplus": "8.5.1"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-googleplus": {}
    },
    "platforms": [
      "electron"
    ]
  }
}

Solution

I managed to find the problem in this line:
https://github.com/apache/cordova-lib/blob/master/src/cordova/platform/addHelper.js#L102

If "dependencies" exists, the code skips the devDependencies.

Version information

cordova-lib@10.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@lirichard
Copy link
Contributor

@aidanas proposed a fix in PR #874. I forked his fork and contributed a unit test as well for completeness: PR aidanas#1.

See also previous closed issue which partially fixed the problem, and a follow-up comment which likely is about this same issue: #832 (comment).

aidanas added a commit to aidanas/cordova-lib that referenced this issue Sep 10, 2021
fix: added unit test for package.json devDependencies (apache#866)
raphinesse pushed a commit that referenced this issue Sep 26, 2021
* fix: Check for platform version in both normal and dev dependencies within package.json file.

* fix: added unit test for package.json devDependencies (#866)

Co-authored-by: Aidanas Tamasauskas <aidana.tamasauskas@nutshellapps.co.uk>
Co-authored-by: Richard Li <li.richard.2013@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants