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

cordova run xxx regularly updates package.json with an empty line #441

Closed
3 tasks done
fcamblor opened this issue Jun 4, 2019 · 4 comments
Closed
3 tasks done

cordova run xxx regularly updates package.json with an empty line #441

fcamblor opened this issue Jun 4, 2019 · 4 comments

Comments

@fcamblor
Copy link

fcamblor commented Jun 4, 2019

Bug Report

Problem

Everytime I run cordova run browser, my package.json file is locally updated :
cordova_run_browser_updates_package_json

What is expected to happen?

package.json is left unmodified, after any cordova run call (which sounds to be idempotent)

What does actually happen?

A new line is added at the end of package.json

Information

You have a reproducer script below

Command or Code

mkdir /tmp/cordova-sample/ && cd /tmp/cordova-sample/
git init && npm init
npm install --save-dev [email protected]
echo node_modules/ > .gitignore
git add . && git commit -m "initial commit"
npx cordova create tmp-cordova && rm tmp-cordova/package.json && mv tmp-cordova/* ./ && rm -Rf tmp-cordova/
echo platforms >> .gitignore
echo plugins >> .gitignore
git add . && git commit -m "created cordova app"
npx cordova platform add [email protected]
git add . && git commit -m "added browser platform"
# installing a random npm package, resulting in changes in package.json
npm install --save-dev noop
git add . && git commit -m "added no-op package"
# running a cordova run command
npx cordova run browser
# End of line appended at the end of the package.json line
git diff

cordova_run_browser_updates_package_json

Environment, Platform, Device

Mac OS X 10.14.4

Version information

Tested on cordova cli 7.1.0, 8.1.2 and 9.0.0
No matter the platform and its version.

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@janpio janpio transferred this issue from apache/cordova Jun 7, 2019
markspanbroek added a commit to global-121/121-indy-wrapper-ios-testapp that referenced this issue Aug 28, 2019
Cordova and npm both update package.json in conflicting ways.
Npm inserts a final newline, and cordova removes a final newline.
We'll stick with cordova's convention for now, because it is most likely
that a cordova command has been called last.

More info: apache/cordova-cli#441
arzyu added a commit to arzyu/cordova-plugin-package-json-guard that referenced this issue Sep 10, 2019
@HarelM
Copy link

HarelM commented Mar 30, 2020

I can confirm this happens to me too.

@fcamblor
Copy link
Author

For history, seems a duplicate of #353 and #394 => closing as 353 is the placeholder for this issue

@fcamblor
Copy link
Author

fcamblor commented Mar 30, 2020

BTW, @arzyu seems to have implemented a plugin just for this purpose ( that's crazy x-D )

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

@HarelM
Copy link

HarelM commented Mar 30, 2020

Totally crazy :-)

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

No branches or pull requests

2 participants