From 4cd43df8aee282f73a40d46ab31c4320f150b9e7 Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Tue, 17 Jan 2023 23:56:17 +0100 Subject: [PATCH 1/6] Add default formatter for vscode (so it overrides users potential prettier default) --- .vscode/settings.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..288646c9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } +} From a5b47236dc8cf5a0be779f2644746f0f144a2961 Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Tue, 17 Jan 2023 23:56:55 +0100 Subject: [PATCH 2/6] Better handling of UnsupportedCommand error --- src/parse.ts | 9 ++++++++- src/runner.ts | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/parse.ts b/src/parse.ts index 1f14f96a..c4e1ecd6 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -3,6 +3,12 @@ import { AGENTS } from './agents' import { exclude } from './utils' import type { Runner } from './runner' +export class UnsupportedCommand extends Error { + constructor({ agent, command }: { agent: Agent; command: Command }) { + super(`Command "${command}" is not support by agent "${agent}"`) + } +} + export function getCommand( agent: Agent, command: Command, @@ -17,7 +23,8 @@ export function getCommand( return c(args) if (!c) - throw new Error(`Command "${command}" is not support by agent "${agent}"`) + throw new UnsupportedCommand({ agent, command }) + return c.replace('{0}', args.join(' ')).trim() } diff --git a/src/runner.ts b/src/runner.ts index cf43e4f9..55a8c4f8 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -10,6 +10,7 @@ import { getDefaultAgent, getGlobalAgent } from './config' import type { DetectOptions } from './detect' import { detect } from './detect' import { getVoltaPrefix, remove } from './utils' +import { UnsupportedCommand } from './parse' const DEBUG_SIGN = '?' @@ -26,6 +27,9 @@ export async function runCli(fn: Runner, options: DetectOptions = {}) { await run(fn, args, options) } catch (error) { + if (error instanceof UnsupportedCommand) + console.log(c.red(`\u2717 ${error.message}`)) + process.exit(1) } } From 7bd74149d1203597567dd134e1c69b8066a399ad Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Fri, 20 Jan 2023 13:32:20 +0100 Subject: [PATCH 3/6] Final newline --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 288646c9..913ee533 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "[typescript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "vscode.typescript-language-features", + "files.insertFinalNewline": true } } From 615792657ae02b680e53d28668f56de4a91e7414 Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Fri, 20 Jan 2023 21:15:35 +0100 Subject: [PATCH 4/6] Remove .vscode --- .vscode/settings.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 913ee533..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "[typescript]": { - "editor.defaultFormatter": "vscode.typescript-language-features", - "files.insertFinalNewline": true - } -} From 0b197655579a4e00e10a5227e3a1545b7a698c98 Mon Sep 17 00:00:00 2001 From: Fran Zekan Date: Fri, 20 Jan 2023 21:15:41 +0100 Subject: [PATCH 5/6] Ignore .vscode folder --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f3b6a33d..3bb4ed9a 100644 --- a/.gitignore +++ b/.gitignore @@ -82,4 +82,6 @@ dist _storage.json # System files -.DS_Store \ No newline at end of file +.DS_Store + +.vscode/ \ No newline at end of file From f45c099dc10c080374a0d957170ef343046eee2c Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 13 Feb 2023 20:14:11 +0100 Subject: [PATCH 6/6] Update .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3bb4ed9a..6ce7699d 100644 --- a/.gitignore +++ b/.gitignore @@ -83,5 +83,3 @@ _storage.json # System files .DS_Store - -.vscode/ \ No newline at end of file