mrm icon indicating copy to clipboard operation
mrm copied to clipboard

Feature request: add `updateLockfile` to `packageJson`

Open ext opened this issue 3 years ago • 0 comments

Some of the fields in package.json is present in package-lock.json, e.g engines. It would be useful to have a helper to update the lockfile as well:

const pkg = packageJson();
pkg.merge({
  engines: {
    node: ">= 12.0",
  },
});
pkg.save();

After pkg.save() it would be useful to have a new function to update the lockfile:

pkg.updateLockfile();

or perhaps a flag to save():

pkg.save({
  updateLockfile: true,
});

My current workaround is to call spawnSync (I noticed execCommand was implemented in that way):

spawnSync("npm", ["install"]);

ext avatar Jun 20 '21 16:06 ext