Skip to content

Commit 1439940

Browse files
committed
fix(cli): package install/publish and plugin sign let the exit signal through their catch
A `this.exit(1)` inside a `try` throws oclif's exit signal, and these commands' catches reported it as a second error line (`✗ EEXIT: 1`). Each affected catch now opens with the `isExitSignal` rethrow, and the exit-signal pin's population is widened from JSON-capable commands to every command. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GiHYRmLSNWTfbX9gVQkpz
1 parent f9a8eb8 commit 1439940

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎packages/cli/src/commands/package/install.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { readFile } from 'node:fs/promises';
2626
import { existsSync } from 'node:fs';
2727
import { resolve as resolvePath } from 'node:path';
2828
import { Args, Command, Flags } from '@oclif/core';
29-
import { printHeader, printKV, printSuccess, printError, printStep } from '../../utils/format.js';
29+
import { printHeader, printKV, printSuccess, printError, printStep, isExitSignal } from '../../utils/format.js';
3030

3131
export default class PackageInstall extends Command {
3232
static override description =
@@ -246,6 +246,7 @@ export default class PackageInstall extends Command {
246246
console.log(` ${storageDir}`);
247247
}
248248
} catch (error) {
249+
if (isExitSignal(error)) throw error;
249250
printError((error as Error).message);
250251
this.exit(1);
251252
}

‎packages/cli/src/commands/package/publish.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { readFile } from 'node:fs/promises';
3232
import { resolve as resolvePath, basename, dirname, isAbsolute } from 'node:path';
3333
import { Args, Command, Flags } from '@oclif/core';
3434
import { PackageSchema } from '@objectstack/spec/marketplace';
35-
import { printHeader, printKV, printSuccess, printError, printStep } from '../../utils/format.js';
35+
import { printHeader, printKV, printSuccess, printError, printStep, isExitSignal } from '../../utils/format.js';
3636
import { DEFAULT_CLOUD_URL, tryReadCloudConfig } from '../../utils/cloud-config.js';
3737
import { resolveCloudActiveEnvironmentId } from '../../utils/active-environment.js';
3838
import { readErrorMessage } from '../../utils/response-envelope.js';
@@ -665,6 +665,7 @@ export default class PackagePublish extends Command {
665665
const iconUrl = iconRes.body?.data?.icon_url ?? iconRes.body?.icon_url;
666666
if (iconUrl) printKV(' Icon URL', String(iconUrl));
667667
} catch (err: any) {
668+
if (isExitSignal(err)) throw err;
668669
printError(`Cannot read --icon-file '${iconPath}': ${err.message}`);
669670
this.exit(1);
670671
return;
@@ -794,6 +795,7 @@ export default class PackagePublish extends Command {
794795
for (const v of violations) console.log(` • ${v}`);
795796
}
796797
} catch (error) {
798+
if (isExitSignal(error)) throw error;
797799
printError((error as Error).message);
798800
this.exit(1);
799801
}

‎packages/cli/src/commands/plugin/sign.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { createPublicKey } from 'node:crypto';
1919
import { resolve as resolvePath } from 'node:path';
2020
import { Args, Command, Flags } from '@oclif/core';
2121
import { parseSignature, signPayload, verifyPayload } from '@objectstack/core';
22-
import { printError, printHeader, printKV, printStep, printSuccess } from '../../utils/format.js';
22+
import { isExitSignal, printError, printHeader, printKV, printStep, printSuccess } from '../../utils/format.js';
2323
import { OSPLUGIN_EXT } from '../../utils/osplugin.js';
2424

2525
export default class PluginSign extends Command {
@@ -99,6 +99,7 @@ export default class PluginSign extends Command {
9999
return;
100100
}
101101
} catch (err) {
102+
if (isExitSignal(err)) throw err;
102103
printError(`Self-verification error: ${(err as Error).message}`);
103104
this.exit(1);
104105
return;

packages/cli/test/json-exit-signal.pin.test.ts renamed to packages/cli/test/exit-signal.pin.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ for (const file of COMMAND_FILES) {
369369
const POPULATION: JsonCommand[] = [];
370370
for (const [cls, file] of classFile) {
371371
const faces = jsonFaces(cls as CommandClass);
372-
if (faces.length === 0) continue;
373372
const chain: string[] = [];
374373
for (let k: unknown = cls; k && classFile.has(k); k = Object.getPrototypeOf(k)) chain.push(classFile.get(k)!);
375374
POPULATION.push({ id: commandId(file), faces, chain });

0 commit comments

Comments
 (0)