Skip to content

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

Open
@ventaur

Description

@ventaur

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions