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

Prevent updating package.json if there are no actual changes #694

Open
ventaur opened this issue Sep 15, 2018 · 1 comment
Open

Prevent updating package.json if there are no actual changes #694

ventaur opened this issue Sep 15, 2018 · 1 comment

Comments

@ventaur
Copy link

ventaur commented Sep 15, 2018

I use several additional tools with Cordova for build management. Some of those watch for changes in files in order to rebuild/redistribute. Many hard-code watching the package.json file for changes. When running cordova serve, that calls cordova prepare, and package.json gets updated (so does config.xml), whether there are actually changes to it or not (e.g., no results from a diff). This causes those build watchers to fire, rebuild, copy some files to www, which causes Cordova's auto-reload to kick in, which updates package.json again, which continues this infinite cycle.

Is there a way to avoid writing the exact same content to package.json that already exists in that file on every restart/reload? I get we need config.xml and package.json to "jive" but if there's no diff between what Cordova is about to write to package.json and what's already in package.json, can we skip the write?

Here is a Gist with my 2 files.

@ventaur ventaur closed this as completed Sep 16, 2018
@ventaur ventaur reopened this Sep 16, 2018
@ventaur
Copy link
Author

ventaur commented Sep 16, 2018

On a related note, when I run cordova serve, the config.xml file has the engine tags listed before the plugin tags, near the end of the file. However, when I run cordova run android --device, the config.xml file has the engine tags listed after the plugin tags, at the very bottom of the file.

Again, the contents of config.xml didn't really change, just the order of tags. Whereas, package.json had zero changes (even to the order of properties), yet was written to, thus updating its modified date.

dpogue added a commit to dpogue/cordova-lib that referenced this issue Jun 2, 2020
This also includes fixes for writing package.json with the correct
newlines, which should address the complaints raised in [1] and possibly
[2].

1. apache/cordova-cli#353
2. apache#694
dpogue added a commit to dpogue/cordova-lib that referenced this issue Jun 2, 2020
This also includes fixes for writing package.json with the correct
newlines, which should address the complaints raised in [1] and possibly
[2].

1. apache/cordova-cli#353
2. apache#694
erisu pushed a commit that referenced this issue Jun 3, 2020
* GH-832: Look at devDeps for restoring platforms

This also includes fixes for writing package.json with the correct
newlines, which should address the complaints raised in [1] and possibly
[2].

1. apache/cordova-cli#353
2. #694

* Ensure a failure to restore stops the build

This has been a recurring frustration over several years, and nobody can
seem to explain why we would want to silently ignore restore failures
for platforms and plugins rather than surfacing them and failing the
remainder of the build steps.
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

2 participants