diff --git a/package-lock.json b/package-lock.json index 42e89d19a5..ab10c732e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.133.1", "license": "MIT", "dependencies": { - "@ryanatkn/belt": "^0.24.9", + "@ryanatkn/belt": "^0.24.10", "chokidar": "^3.6.0", "dotenv": "^16.4.5", "es-module-lexer": "^1.5.4", @@ -28,7 +28,7 @@ "@changesets/changelog-git": "^0.2.0", "@changesets/types": "^6.0.0", "@ryanatkn/eslint-config": "^0.4.2", - "@ryanatkn/fuz": "^0.115.0", + "@ryanatkn/fuz": "^0.115.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/adapter-static": "^3.0.2", "@sveltejs/kit": "^2.5.18", @@ -401,9 +401,9 @@ "peer": true }, "node_modules/@ryanatkn/belt": { - "version": "0.24.9", - "resolved": "https://registry.npmjs.org/@ryanatkn/belt/-/belt-0.24.9.tgz", - "integrity": "sha512-rr7loJweYavGNsFXWBYqhkoqhDaXxQrDos5ps5Gphxm7NjngtJfN/ofbehg+3RgtCm3dMGa391N4aJsF3Ak6Kg==", + "version": "0.24.10", + "resolved": "https://registry.npmjs.org/@ryanatkn/belt/-/belt-0.24.10.tgz", + "integrity": "sha512-CrWshOlp+tiqJotCjceT5PaPTgIu5lcwjQsXAk6Ma2R+ZeO4FgYWiHm5RYSyzuaSV9B2qiUXVhMA6nnGIz7S9Q==", "license": "MIT", "engines": { "node": ">=20.12" @@ -446,9 +446,9 @@ } }, "node_modules/@ryanatkn/fuz": { - "version": "0.115.0", - "resolved": "https://registry.npmjs.org/@ryanatkn/fuz/-/fuz-0.115.0.tgz", - "integrity": "sha512-AbLSraP8uKgjinSo9FHCkWDnYt57MqNJOuEaG5sTzkXVsQ6bFrf6ScNLYefoNWPqMtmeURn7ilgBA7d7kaelKw==", + "version": "0.115.1", + "resolved": "https://registry.npmjs.org/@ryanatkn/fuz/-/fuz-0.115.1.tgz", + "integrity": "sha512-fzkk6SnFeeRbWsx6MXmny/nS++fv05y4tTUXqqvaA/KjMI35gUQ1DFAgamLkB0sl72FFo5x9nRNrnE2YHWE0gw==", "dev": true, "license": "MIT", "engines": { @@ -459,44 +459,15 @@ }, "peerDependencies": { "@ryanatkn/belt": "^0.24.9", - "@ryanatkn/gro": "^0.133.0", + "@ryanatkn/gro": "^0.133.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/kit": "^2", "svelte": "^5.0.0-next.0" - } - }, - "node_modules/@ryanatkn/gro": { - "version": "0.133.0", - "resolved": "https://registry.npmjs.org/@ryanatkn/gro/-/gro-0.133.0.tgz", - "integrity": "sha512-DaHScC2mI8K40+fx/nkWKmtGRl0k7XS5KWSOHE/hW2cuBFaKV36z+wJfKID2dqnSYJtY6NbBB6ldCC/GB5vexA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@ryanatkn/belt": "^0.24.9", - "chokidar": "^3.6.0", - "dotenv": "^16.4.5", - "es-module-lexer": "^1.5.4", - "esm-env": "^1.0.0", - "mri": "^1.2.0", - "prettier": "^3.3.3", - "prettier-plugin-svelte": "^3.2.5", - "ts-morph": "^23.0.0", - "tslib": "^2.6.3", - "zod": "^3.23.8" - }, - "bin": { - "gro": "dist/gro.js" - }, - "engines": { - "node": ">=20.12" - }, - "funding": { - "url": "https://www.ryanatkn.com/funding" }, - "peerDependencies": { - "esbuild": "^0.21.0", - "svelte": "^5.0.0-next.0" + "peerDependenciesMeta": { + "@ryanatkn/gro": { + "optional": true + } } }, "node_modules/@ryanatkn/moss": { diff --git a/package.json b/package.json index 9d4f713380..571a64977d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "typescript" ], "dependencies": { - "@ryanatkn/belt": "^0.24.9", + "@ryanatkn/belt": "^0.24.10", "chokidar": "^3.6.0", "dotenv": "^16.4.5", "es-module-lexer": "^1.5.4", @@ -69,7 +69,7 @@ "@changesets/changelog-git": "^0.2.0", "@changesets/types": "^6.0.0", "@ryanatkn/eslint-config": "^0.4.2", - "@ryanatkn/fuz": "^0.115.0", + "@ryanatkn/fuz": "^0.115.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/adapter-static": "^3.0.2", "@sveltejs/kit": "^2.5.18", diff --git a/src/lib/invoke.ts b/src/lib/invoke.ts index aef4bb966b..96a2a103d6 100644 --- a/src/lib/invoke.ts +++ b/src/lib/invoke.ts @@ -17,8 +17,9 @@ and the rest of the args are forwarded to the task's `run` function. */ // handle uncaught errors -attach_process_error_handlers((err) => - err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null, +attach_process_error_handlers( + (err) => (err.constructor.name === 'Task_Error' ? 'Task_Error' : null), + (err) => (err.constructor.name === 'Silent_Error' ? '' : null), ); await sveltekit_sync_if_obviously_needed(); diff --git a/src/lib/invoke_task.ts b/src/lib/invoke_task.ts index d0b728a7a1..7d0a1ffaa7 100644 --- a/src/lib/invoke_task.ts +++ b/src/lib/invoke_task.ts @@ -6,7 +6,7 @@ import {print_ms, print_timings} from '@ryanatkn/belt/print.js'; import {to_forwarded_args, type Args} from './args.js'; import {run_task} from './run_task.js'; import {to_input_path, Raw_Input_Path} from './input_path.js'; -import {find_tasks, load_tasks} from './task.js'; +import {find_tasks, load_tasks, Silent_Error} from './task.js'; import {load_gro_package_json} from './package_json.js'; import {log_tasks, log_error_reasons} from './task_logging.js'; import type {Gro_Config} from './gro_config.js'; @@ -69,7 +69,7 @@ export const invoke_task = async ( const found = find_tasks([input_path], task_root_dirs, config); if (!found.ok) { log_error_reasons(log, found.reasons); - process.exit(1); + throw new Silent_Error(); } // Found a match either in the current working directory or Gro's directory. @@ -80,7 +80,7 @@ export const invoke_task = async ( const loaded = await load_tasks(found_tasks); if (!loaded.ok) { log_error_reasons(log, loaded.reasons); - process.exit(1); + throw new Silent_Error(); } const loaded_tasks = loaded.value; diff --git a/src/lib/package.ts b/src/lib/package.ts index 0c5779f635..1725a0727f 100644 --- a/src/lib/package.ts +++ b/src/lib/package.ts @@ -44,7 +44,7 @@ export const package_json = { 'typescript', ], dependencies: { - '@ryanatkn/belt': '^0.24.9', + '@ryanatkn/belt': '^0.24.10', chokidar: '^3.6.0', dotenv: '^16.4.5', 'es-module-lexer': '^1.5.4', @@ -61,7 +61,7 @@ export const package_json = { '@changesets/changelog-git': '^0.2.0', '@changesets/types': '^6.0.0', '@ryanatkn/eslint-config': '^0.4.2', - '@ryanatkn/fuz': '^0.115.0', + '@ryanatkn/fuz': '^0.115.1', '@ryanatkn/moss': '^0.8.0', '@sveltejs/adapter-static': '^3.0.2', '@sveltejs/kit': '^2.5.18', @@ -964,6 +964,7 @@ export const src_json = { {name: 'is_task_path', kind: 'function'}, {name: 'to_task_name', kind: 'function'}, {name: 'Task_Error', kind: 'class'}, + {name: 'Silent_Error', kind: 'class'}, {name: 'Found_Task', kind: 'type'}, {name: 'Found_Tasks', kind: 'type'}, {name: 'Find_Tasks_Result', kind: 'type'}, diff --git a/src/lib/task.ts b/src/lib/task.ts index fd62766531..e2af424e07 100644 --- a/src/lib/task.ts +++ b/src/lib/task.ts @@ -80,6 +80,12 @@ export const to_task_name = ( */ export class Task_Error extends Error {} +/** + * This is used to tell Gro to exit silently, usually still with with a non-zero exit code. + * Using it means error logging is handled by the code that threw it. + */ +export class Silent_Error extends Error {} + export interface Found_Task { input_path: Input_Path; id: Path_Id;