From da06a079a049716139c817b103a18e3b0bb42adf Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Thu, 17 Aug 2023 11:37:55 -0400 Subject: [PATCH] Support v3 lockfiles in npmUpdate script Signed-off-by: Timothy Johnson --- dist/run-script.js | 4 ++-- packages/run-script/scripts/npmUpdate.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/run-script.js b/dist/run-script.js index e61da33..8dfc445 100644 --- a/dist/run-script.js +++ b/dist/run-script.js @@ -3673,8 +3673,8 @@ function getDependencies(context3, branch, dev) { function updateDependency(context3, pkgName, pkgTag, dev) { return __async(this, null, function* () { context3.logger.debug(`Updating ${dev ? "devD" : "d"}ependency for: ${pkgName}@${pkgTag}`); - const lockfile = JSON.parse(fs.readFileSync(lockfilePath, "utf-8")); - const currentVersion = lockfile.dependencies[pkgName].version; + const cmdOutput = (yield exec.getExecOutput("npm", ["list", pkgName, "--json", "--depth", "0"])).stdout; + const currentVersion = JSON.parse(cmdOutput).dependencies[pkgName].version; if (resolutions[pkgName] == null) { context3.logger.debug(`Gathering version information for: ${pkgName}@${pkgTag}`); resolutions[pkgName] = (yield exec.getExecOutput( diff --git a/packages/run-script/scripts/npmUpdate.ts b/packages/run-script/scripts/npmUpdate.ts index d0916e7..27d9ea9 100644 --- a/packages/run-script/scripts/npmUpdate.ts +++ b/packages/run-script/scripts/npmUpdate.ts @@ -46,8 +46,8 @@ function getDependencies(context: IContext, branch: IProtectedBranchWithDeps, de async function updateDependency(context: IContext, pkgName: string, pkgTag: string, dev: boolean): Promise { context.logger.debug(`Updating ${dev ? "devD" : "d"}ependency for: ${pkgName}@${pkgTag}`); - const lockfile = JSON.parse(fs.readFileSync(lockfilePath, "utf-8")); - const currentVersion = lockfile.dependencies[pkgName].version; + const cmdOutput = (await exec.getExecOutput("npm", ["list", pkgName, "--json", "--depth", "0"])).stdout; + const currentVersion = JSON.parse(cmdOutput).dependencies[pkgName].version; if (resolutions[pkgName] == null) { context.logger.debug(`Gathering version information for: ${pkgName}@${pkgTag}`);