From 9e516a8495dee9a1d789d45fbe6b4c0a3786fbf2 Mon Sep 17 00:00:00 2001 From: Rahul Gautam Singh Date: Wed, 11 Sep 2024 13:22:14 +0530 Subject: [PATCH] write existing changes first --- lib/modules/manager/npm/artifacts.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/npm/artifacts.ts b/lib/modules/manager/npm/artifacts.ts index 13522f50284267..082dc4348821eb 100644 --- a/lib/modules/manager/npm/artifacts.ts +++ b/lib/modules/manager/npm/artifacts.ts @@ -2,7 +2,7 @@ import upath from 'upath'; import { logger } from '../../../logger'; import { exec } from '../../../util/exec'; import type { ExecOptions } from '../../../util/exec/types'; -import { readLocalFile } from '../../../util/fs'; +import { readLocalFile, writeLocalFile } from '../../../util/fs'; import { regEx } from '../../../util/regex'; import type { UpdateArtifact, UpdateArtifactsResult } from '../types'; import { getNodeToolConstraint } from './post-update/node-version'; @@ -37,6 +37,9 @@ export async function updateArtifacts({ return null; } + // write old updates before executing corepack update so that they are not removed from package file + await writeLocalFile(packageFileName, existingPackageFileContent); + // Asumming that corepack only needs to modify the package.json file in the root folder // As it should not be regular practice to have different package managers in different workspaces const pkgFileDir = upath.dirname(packageFileName);