You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/10/28 04:30:38 UTC

[GitHub] [cordova-lib] dpogue opened a new pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

dpogue opened a new pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860


   ### Platforms affected
   all
   
   
   ### Motivation and Context
   <!-- Why is this change required? What problem does it solve? -->
   <!-- If it fixes an open issue, please link to the issue here. -->
   We are looking at the possibility of having most of the platform tooling code run out of `node_modules` instead of being copied into the `platforms` folder. This allows loading the Platform API from either `platforms` or `node_modules`.
   
   
   ### Description
   <!-- Describe your changes in detail -->
   Try loading the Platform API from the `platforms` folder, but failing that, require the main file from the platform package.json in `node_modules`.
   
   
   ### Testing
   <!-- Please describe in detail how you tested your changes. -->
   Still needs tests
   
   
   ### Checklist
   
   - [ ] I've run the tests to see all new and existing tests pass
   - [ ] I added automated test coverage as appropriate for this change


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] raphinesse commented on a change in pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

Posted by GitBox <gi...@apache.org>.
raphinesse commented on a change in pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#discussion_r716220531



##########
File path: src/cordova/util.js
##########
@@ -301,14 +301,26 @@ function isDirectory (dir) {
 
 // Returns the API of the platform contained in `dir`.
 // Potential errors : module isn't found, can't load or doesn't implement the expected interface.
-function getPlatformApiFunction (dir) {
+function getPlatformApiFunction (dir, platform) {
     let PlatformApi;
     try {
+        // First try to load the platform API from the platform project
+        // This is necessary to support older platform API versions
         PlatformApi = exports.requireNoCache(dir);
     } catch (err) {
-        // Module not found or threw error during loading
-        err.message = `Unable to load Platform API from ${dir}:\n${err.message}`;
-        throw err;
+        try {
+            let cdvPlatform = platform;
+            if (!platform.startsWith('cordova-')) {
+                cdvPlatform = `cordova-${platform}`;
+            }

Review comment:
       Different way to do the same thing:
   ```suggestion
               const cdvPlatform = platform.replace(/^(?:cordova-)?/, 'cordova-');
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] codecov-io edited a comment on pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#issuecomment-717690172


   # [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=h1) Report
   > Merging [#860](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=desc) into [master](https://codecov.io/gh/apache/cordova-lib/commit/73d0155df414989eb15b327bf14c0f04bc3fed11?el=desc) will **decrease** coverage by `0.22%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-lib/pull/860/graphs/tree.svg?width=650&height=150&src=pr&token=KwBjKMXLqA)](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #860      +/-   ##
   ==========================================
   - Coverage   91.18%   90.96%   -0.23%     
   ==========================================
     Files          45       45              
     Lines        2054     2059       +5     
   ==========================================
     Hits         1873     1873              
   - Misses        181      186       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [src/cordova/util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree#diff-c3JjL2NvcmRvdmEvdXRpbC5qcw==) | `90.47% <0.00%> (-3.19%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=footer). Last update [73d0155...2cde5e2](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] dpogue commented on a change in pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

Posted by GitBox <gi...@apache.org>.
dpogue commented on a change in pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#discussion_r513174314



##########
File path: src/cordova/util.js
##########
@@ -301,14 +301,23 @@ function isDirectory (dir) {
 
 // Returns the API of the platform contained in `dir`.
 // Potential errors : module isn't found, can't load or doesn't implement the expected interface.
-function getPlatformApiFunction (dir) {
+function getPlatformApiFunction (dir, platform) {

Review comment:
       Apparently we were already passing in the platform name as a second parameter, but not using it 🤷🏼‍♂️ 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] codecov-commenter edited a comment on pull request #860: feat(cordova/util): support requiring platform API from node_modules

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#issuecomment-927325493


   # [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#860](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f21b480) into [master](https://codecov.io/gh/apache/cordova-lib/commit/73d0155df414989eb15b327bf14c0f04bc3fed11?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (73d0155) will **decrease** coverage by `0.22%`.
   > The diff coverage is `35.71%`.
   
   > :exclamation: Current head f21b480 differs from pull request most recent head 8d8133f. Consider uploading reports for the commit 8d8133f to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-lib/pull/860/graphs/tree.svg?width=650&height=150&src=pr&token=KwBjKMXLqA&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #860      +/-   ##
   ==========================================
   - Coverage   91.18%   90.96%   -0.23%     
   ==========================================
     Files          45       45              
     Lines        2054     2058       +4     
   ==========================================
   - Hits         1873     1872       -1     
   - Misses        181      186       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [src/cordova/requirements.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVxdWlyZW1lbnRzLmpz) | `54.54% <0.00%> (-9.10%)` | :arrow_down: |
   | [src/cordova/restore-util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVzdG9yZS11dGlsLmpz) | `93.33% <ø> (+0.83%)` | :arrow_up: |
   | [src/cordova/util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvdXRpbC5qcw==) | `90.47% <0.00%> (-3.19%)` | :arrow_down: |
   | [src/cordova/platform/addHelper.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcGxhdGZvcm0vYWRkSGVscGVyLmpz) | `94.73% <100.00%> (ø)` | |
   | [src/cordova/serve.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvc2VydmUuanM=) | `100.00% <100.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [73d0155...8d8133f](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] raphinesse merged pull request #860: feat(cordova/util): support requiring platform API from node_modules

Posted by GitBox <gi...@apache.org>.
raphinesse merged pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] codecov-commenter commented on pull request #860: feat(cordova/util): support requiring platform API from node_modules

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#issuecomment-927325493


   # [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#860](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f21b480) into [master](https://codecov.io/gh/apache/cordova-lib/commit/73d0155df414989eb15b327bf14c0f04bc3fed11?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (73d0155) will **decrease** coverage by `0.22%`.
   > The diff coverage is `35.71%`.
   
   > :exclamation: Current head f21b480 differs from pull request most recent head 8d8133f. Consider uploading reports for the commit 8d8133f to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-lib/pull/860/graphs/tree.svg?width=650&height=150&src=pr&token=KwBjKMXLqA&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #860      +/-   ##
   ==========================================
   - Coverage   91.18%   90.96%   -0.23%     
   ==========================================
     Files          45       45              
     Lines        2054     2058       +4     
   ==========================================
   - Hits         1873     1872       -1     
   - Misses        181      186       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [src/cordova/requirements.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVxdWlyZW1lbnRzLmpz) | `54.54% <0.00%> (-9.10%)` | :arrow_down: |
   | [src/cordova/restore-util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVzdG9yZS11dGlsLmpz) | `93.33% <ø> (+0.83%)` | :arrow_up: |
   | [src/cordova/util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvdXRpbC5qcw==) | `90.47% <0.00%> (-3.19%)` | :arrow_down: |
   | [src/cordova/platform/addHelper.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcGxhdGZvcm0vYWRkSGVscGVyLmpz) | `94.73% <100.00%> (ø)` | |
   | [src/cordova/serve.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvc2VydmUuanM=) | `100.00% <100.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [73d0155...8d8133f](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] codecov-io commented on pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#issuecomment-717690172


   # [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=h1) Report
   > Merging [#860](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=desc) into [master](https://codecov.io/gh/apache/cordova-lib/commit/73d0155df414989eb15b327bf14c0f04bc3fed11?el=desc) will **decrease** coverage by `0.22%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-lib/pull/860/graphs/tree.svg?width=650&height=150&src=pr&token=KwBjKMXLqA)](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #860      +/-   ##
   ==========================================
   - Coverage   91.18%   90.96%   -0.23%     
   ==========================================
     Files          45       45              
     Lines        2054     2059       +5     
   ==========================================
     Hits         1873     1873              
   - Misses        181      186       +5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [src/cordova/util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree#diff-c3JjL2NvcmRvdmEvdXRpbC5qcw==) | `90.47% <0.00%> (-3.19%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=footer). Last update [73d0155...2cde5e2](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] codecov-commenter edited a comment on pull request #860: feat(cordova/util): support requiring platform API from node_modules

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#issuecomment-927325493


   # [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#860](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dba211e) into [master](https://codecov.io/gh/apache/cordova-lib/commit/73d0155df414989eb15b327bf14c0f04bc3fed11?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (73d0155) will **decrease** coverage by `0.02%`.
   > The diff coverage is `66.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/cordova-lib/pull/860/graphs/tree.svg?width=650&height=150&src=pr&token=KwBjKMXLqA&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #860      +/-   ##
   ==========================================
   - Coverage   91.18%   91.16%   -0.03%     
   ==========================================
     Files          45       45              
     Lines        2054     2059       +5     
   ==========================================
   + Hits         1873     1877       +4     
   - Misses        181      182       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [src/cordova/util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvdXRpbC5qcw==) | `93.24% <66.66%> (-0.42%)` | :arrow_down: |
   | [src/cordova/requirements.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVxdWlyZW1lbnRzLmpz) | `54.54% <0.00%> (-9.10%)` | :arrow_down: |
   | [src/cordova/serve.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvc2VydmUuanM=) | `100.00% <0.00%> (ø)` | |
   | [src/cordova/platform/addHelper.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcGxhdGZvcm0vYWRkSGVscGVyLmpz) | `94.73% <0.00%> (ø)` | |
   | [src/cordova/restore-util.js](https://codecov.io/gh/apache/cordova-lib/pull/860/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL2NvcmRvdmEvcmVzdG9yZS11dGlsLmpz) | `93.33% <0.00%> (+0.83%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [73d0155...dba211e](https://codecov.io/gh/apache/cordova-lib/pull/860?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-lib] raphinesse commented on a change in pull request #860: fix(cordova/util): Support requiring PlatformAPI from node_modules

Posted by GitBox <gi...@apache.org>.
raphinesse commented on a change in pull request #860:
URL: https://github.com/apache/cordova-lib/pull/860#discussion_r513236895



##########
File path: src/cordova/util.js
##########
@@ -301,14 +301,23 @@ function isDirectory (dir) {
 
 // Returns the API of the platform contained in `dir`.
 // Potential errors : module isn't found, can't load or doesn't implement the expected interface.
-function getPlatformApiFunction (dir) {
+function getPlatformApiFunction (dir, platform) {
     let PlatformApi;
     try {
         PlatformApi = exports.requireNoCache(dir);

Review comment:
       ```suggestion
           // First try to load the platform API from the platform project
           // This is necessary to support older platform API versions
           PlatformApi = exports.requireNoCache(dir);
   ```

##########
File path: src/cordova/util.js
##########
@@ -301,14 +301,23 @@ function isDirectory (dir) {
 
 // Returns the API of the platform contained in `dir`.
 // Potential errors : module isn't found, can't load or doesn't implement the expected interface.
-function getPlatformApiFunction (dir) {
+function getPlatformApiFunction (dir, platform) {
     let PlatformApi;
     try {
         PlatformApi = exports.requireNoCache(dir);
     } catch (err) {
-        // Module not found or threw error during loading
-        err.message = `Unable to load Platform API from ${dir}:\n${err.message}`;
-        throw err;
+        try {
+            let cdvPlatform = platform;
+            if (!platform.startsWith('cordova-')) {
+                cdvPlatform = `cordova-${platform}`;
+            }
+
+            PlatformApi = exports.requireNoCache(cdvPlatform);

Review comment:
       ```suggestion
               // Load the platform API directly from node_modules
               PlatformApi = exports.requireNoCache(cdvPlatform);
   ```
   
   Do we need `requireNoCache` here? I guess not. But I'm not entirely sure.

##########
File path: src/cordova/util.js
##########
@@ -301,14 +301,23 @@ function isDirectory (dir) {
 
 // Returns the API of the platform contained in `dir`.
 // Potential errors : module isn't found, can't load or doesn't implement the expected interface.
-function getPlatformApiFunction (dir) {
+function getPlatformApiFunction (dir, platform) {
     let PlatformApi;
     try {
         PlatformApi = exports.requireNoCache(dir);
     } catch (err) {
-        // Module not found or threw error during loading
-        err.message = `Unable to load Platform API from ${dir}:\n${err.message}`;
-        throw err;
+        try {

Review comment:
       Maybe only retry if `err.code === 'MODULE_NOT_FOUND'`? Not sure what would be better here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org