apache / apache/cordova-lib

Prevent updating package.json if there are no actual changes

Open
#694 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
231
Forks
242
Avg merge
2h 51m
Merged PRs (30d)
7

Description

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](https://gist.github.com/ventaur/a2b568b39a3b11bf5a7b4a75bb097605).

Contributor guide

Open the contributing guide

Research direction

Start by tracing the cordova prepare path called by cordova serve and identify where package.json is written. Compare the content to the existing file before writing; done means identical content is not rewritten while actual changes still update package.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.