Skip to content

Commit

Permalink
Merge branch 'fix/exit-code-1-on-error' into release/cmd-1.1.1-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
vCaisim committed Oct 3, 2024
2 parents ad34b54 + 7b7c1fa commit 6fae208
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/cmd/src/commands/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export async function commandHandler<T extends Record<string, unknown>>(
process.exit(0);
} catch (e) {
const failOnError = options?.failOnError ?? true;
let exitCode = e instanceof CommanderError ? e.exitCode : 1;

if (
e instanceof CommanderError ||
Expand All @@ -40,12 +39,12 @@ export async function commandHandler<T extends Record<string, unknown>>(
error(e.message);
} else {
warnWithNoTrace(e.message);
exitCode = 0;
}
} else {
error('Script execution failed: %o', e);
}

process.exit(exitCode);
const exitCode = e instanceof CommanderError ? e.exitCode : 1;
process.exit(failOnError ? exitCode : 0);
}
}
3 changes: 3 additions & 0 deletions packages/cmd/src/services/cache/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { retrieveCache } from '../../api';
import { PRESETS } from '../../commands/cache/options';
import { getCacheCommandConfig } from '../../config/cache';
import { getCI } from '../../env/ciProvider';
import { success } from '../../logger';
import { unzipBuffer } from './fs';
import { MetaFile } from './lib';
import { download } from './network';
Expand Down Expand Up @@ -45,6 +46,8 @@ export async function handleGetCache() {
if (preset === PRESETS.lastRun) {
await handlePostLastRunPreset(config.values, ci, meta);
}

success('Cache restored. Cache ID: %s', result.cacheId);
} catch (e) {
if (isAxiosError(e)) {
if (
Expand Down
3 changes: 3 additions & 0 deletions packages/cmd/src/services/cache/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createCache } from '../../api';
import { PRESETS } from '../../commands/cache/options';
import { getCacheCommandConfig } from '../../config/cache';
import { getCI } from '../../env/ciProvider';
import { success } from '../../logger';
import { filterPaths, zipFilesToBuffer } from './fs';
import { createMeta, getLastRunFilePath } from './lib';
import {
Expand Down Expand Up @@ -66,6 +67,8 @@ export async function handleSetCache() {
cacheId: result.cacheId,
uploadUrl: result.metaUploadUrl,
});

success('Cache uploaded. Cache ID: %s', result.cacheId);
}

async function handleArchiveUpload({
Expand Down

0 comments on commit 6fae208

Please sign in to comment.