Skip to content

Commit

Permalink
fix(release): parse NPM output for JSON to prevent JSON.parse from th…
Browse files Browse the repository at this point in the history
…rowing

closed nrwl#22925
  • Loading branch information
gutentag2012 authored and gutentag2012 committed May 2, 2024
1 parent abd80cf commit 2e37549
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ export default async function runExecutor(
stdio: ['ignore', 'pipe', 'pipe'],
});

const stdoutData = JSON.parse(output.toString());
const jsonRegex = /\{(?:[^{}])*\}/g;
const jsonObjectsInOutput = output.toString().match(jsonRegex);
const stdoutData = JSON.parse(
jsonObjectsInOutput[jsonObjectsInOutput.length - 1]
);

// If npm workspaces are in use, the publish output will nest the data under the package name, so we normalize it first
const normalizedStdoutData = stdoutData[packageName] ?? stdoutData;
Expand Down

0 comments on commit 2e37549

Please sign in to comment.