node-power-user 1.0.5 → 1.0.7

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/cli.js +20 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -15,13 +15,28 @@ const ALIASES = {
15
15
  };
16
16
 
17
17
  // Function to resolve command name from aliases
18
- function resolveCommand(command) {
18
+ function resolveCommand(options) {
19
+ // Check if a command was explicitly passed via positional argument
20
+ if (options._.length > 0) {
21
+ const command = options._[0];
22
+ for (const [key, aliases] of Object.entries(ALIASES)) {
23
+ if (command === key || aliases.includes(command)) {
24
+ return key;
25
+ }
26
+ }
27
+ return command; // If not found in aliases, return as-is
28
+ }
29
+
30
+ // Check if any alias was passed as a flag (e.g., -g)
19
31
  for (const [key, aliases] of Object.entries(ALIASES)) {
20
- if (command === key || aliases.includes(command)) {
21
- return key;
32
+ for (const alias of aliases) {
33
+ if (options[alias.replace(/^-+/, '')]) { // Remove leading `-`
34
+ return key;
35
+ }
22
36
  }
23
37
  }
24
- return command; // Default to original command if no alias is found
38
+
39
+ return DEFAULT; // Fallback to default if no match is found
25
40
  }
26
41
 
27
42
  // Main Function
@@ -29,8 +44,7 @@ function Main() {}
29
44
 
30
45
  Main.prototype.process = async function (options) {
31
46
  // Determine the command (use default if not provided)
32
- const inputCommand = options._[0] || DEFAULT;
33
- const command = resolveCommand(inputCommand);
47
+ const command = resolveCommand(options);
34
48
 
35
49
  try {
36
50
  // Get the command file path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-power-user",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Easy tools for every Node.js developer!",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {