mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 07:30:52 -07:00
be smarter about ls issues.
This commit is contained in:
@@ -36,9 +36,35 @@ run(`npm version ${versionType} --no-git-tag-version --allow-same-version`);
|
||||
|
||||
// 3. Get all workspaces and filter out the one we don't want to version.
|
||||
const workspacesToExclude = [];
|
||||
const lsOutput = JSON.parse(
|
||||
execSync('npm ls --workspaces --json --depth=0').toString(),
|
||||
);
|
||||
let lsOutput;
|
||||
try {
|
||||
lsOutput = JSON.parse(
|
||||
execSync('npm ls --workspaces --json --depth=0').toString(),
|
||||
);
|
||||
} catch (e) {
|
||||
// `npm ls` can exit with a non-zero status code if there are issues
|
||||
// with dependencies, but it will still produce the JSON output we need.
|
||||
// We'll try to parse the stdout from the error object.
|
||||
if (e.stdout) {
|
||||
console.warn(
|
||||
'Warning: `npm ls` exited with a non-zero status code. Attempting to proceed with the output.',
|
||||
);
|
||||
try {
|
||||
lsOutput = JSON.parse(e.stdout.toString());
|
||||
} catch (parseError) {
|
||||
console.error(
|
||||
'Error: Failed to parse JSON from `npm ls` output even after `npm ls` failed.',
|
||||
);
|
||||
console.error('npm ls stderr:', e.stderr.toString());
|
||||
console.error('Parse error:', parseError);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error('Error: `npm ls` failed with no output.');
|
||||
console.error(e.stderr?.toString() || e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
const allWorkspaces = Object.keys(lsOutput.dependencies || {});
|
||||
const workspacesToVersion = allWorkspaces.filter(
|
||||
(wsName) => !workspacesToExclude.includes(wsName),
|
||||
|
||||
Reference in New Issue
Block a user