@clerc/plugin-not-found 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +10 -10
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NoCommandGivenError, NoSuchCommandError, definePlugin } from "@clerc/core";
1
+ import { NoCommandSpecifiedError, NoSuchCommandError, definePlugin } from "@clerc/core";
2
2
  import didyoumean from "didyoumean2";
3
3
  import * as yc from "yoctocolors";
4
4
 
@@ -11,18 +11,18 @@ const notFoundPlugin = () => definePlugin({ setup: (cli) => cli.interceptor({
11
11
  try {
12
12
  await next();
13
13
  } catch (e) {
14
- if (!(e instanceof NoSuchCommandError || e instanceof NoCommandGivenError)) throw e;
15
- if (e instanceof NoCommandGivenError) {
16
- console.error("No command specified.");
17
- if (hasCommands) console.error(`Possible commands: ${commandKeys.join(", ")}`);
18
- return;
14
+ if (!(e instanceof NoSuchCommandError || e instanceof NoCommandSpecifiedError)) throw e;
15
+ if (e instanceof NoCommandSpecifiedError) {
16
+ let text$1 = "No command specified.";
17
+ if (hasCommands) text$1 += `\nPossible commands: ${commandKeys.join(", ")}.`;
18
+ throw new NoCommandSpecifiedError(text$1);
19
19
  }
20
20
  const { commandName } = e;
21
21
  const closestCommandName = didyoumean(commandName, commandKeys);
22
- console.error(`Command "${yc.strikethrough(commandName)}" not found.`);
23
- if (hasCommands && closestCommandName) console.error(`Did you mean "${yc.bold(closestCommandName)}"?`);
24
- else if (!hasCommands) console.error("No commands registered.");
25
- process.exit(2);
22
+ let text = `Command "${yc.strikethrough(commandName)}" not found.`;
23
+ if (hasCommands && closestCommandName) text += `\nDid you mean "${yc.bold(closestCommandName)}"?`;
24
+ else if (!hasCommands) text += "\nNo commands registered.";
25
+ throw new NoSuchCommandError(commandName, text);
26
26
  }
27
27
  }
28
28
  }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-not-found",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.2",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc plugin not found (did you mean)",
@@ -47,10 +47,10 @@
47
47
  "dependencies": {
48
48
  "didyoumean2": "^7.0.4",
49
49
  "yoctocolors": "^2.1.2",
50
- "@clerc/utils": "1.0.0-beta.1"
50
+ "@clerc/utils": "1.0.0-beta.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@clerc/core": "1.0.0-beta.1"
53
+ "@clerc/core": "1.0.0-beta.2"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@clerc/core": "*"