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

Package.json is being modified after cordova build android #394

Closed
distante opened this issue Jan 2, 2019 · 7 comments
Closed

Package.json is being modified after cordova build android #394

distante opened this issue Jan 2, 2019 · 7 comments

Comments

@distante
Copy link

distante commented Jan 2, 2019

Description:
I work in a windows environment with vscode where all files need to end with CRLF , so this configs are made:

  • .editorconfig the end_of_line property is set to crlf
  • git uses crlf
  • .prettierrc has "endOfLine": "crlf"
  • vscode config has "files.eol": "\r\n" and "prettier.endOfLine": "crlf"

All work as expected except for when you build (or run) the project on device. > cordova build android the package.json file is edited and stripped from the last empty line. That leads git say changes where made and the tree is not clean.

Steps to Reproduce:

  • Make a clean cordova project (or if you use Ionic as I do, then an ionic empty project)
  • Set eol to crlf
  • Add platform Android
  • Make sure package.json has a empty new line in the end.
  • Run cordova build android

Output:
image

I had this problem with cordova version 8.0.0 and right now with 8.1.2

Edit: As per this comment, this problem also happens in iOS

@jwhitmarsh
Copy link

Affecting iOS too

@doug-a-brunner
Copy link

Still exists on CLI 9.0.0.

@dpogue
Copy link
Member

dpogue commented Apr 5, 2019

Yep, this won't be fixed until we do a complete refactor of our package.json handling. The first part of that is apache/cordova-common#34 which needs a lot more work before it's ready to merge

@raphinesse
Copy link
Contributor

AFAICT, this is a duplicate of #353. Someone please yell at me if that's not right. Closing for now.

arzyu added a commit to arzyu/cordova-plugin-package-json-guard that referenced this issue Sep 10, 2019
@arzyu
Copy link

arzyu commented Sep 10, 2019

I created a plugin to solve this issue.

https://github.com/arzyu/cordova-plugin-package-json-guard

@u01jmg3
Copy link

u01jmg3 commented Jun 10, 2020

Plugin from @arzyu did the trick

Now I don't need to battle with npm and cordova over having a trailing newline in package.json

diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -95,4 +95,4 @@
         }
     }
-}
+}
\ No newline at end of file

@gunhaxxor
Copy link

I created a plugin to solve this issue.

https://github.com/arzyu/cordova-plugin-package-json-guard

How about config.xml? Do the plugin handle that aswell?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants