@catladder/cli 4.0.0 → 4.0.1

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.
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "4.0.0",
56
+ "version": "4.0.1",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -146,17 +146,22 @@ class TerminalContext<
146
146
  return jsonInputs[name] as InputResultType<P>;
147
147
  }
148
148
 
149
- // 3. Interactive prompt
150
- if (isInteractive) {
151
- return promptInteractive({ ...spec, name }, this);
152
- }
153
-
154
- // 4. Default
149
+ // 3. Default (check before prompting, so optional inputs with defaults don't prompt)
155
150
  if ("default" in spec && spec.default !== undefined) {
156
151
  return spec.default as InputResultType<P>;
157
152
  }
158
153
 
159
- // 5. Throw
154
+ // 4. Optional inputs: don't prompt, throw so baseContext returns undefined
155
+ if (spec.required === false) {
156
+ throw new MissingInputError(name, spec.message);
157
+ }
158
+
159
+ // 5. Interactive prompt
160
+ if (isInteractive) {
161
+ return promptInteractive({ ...spec, name }, this);
162
+ }
163
+
164
+ // 6. Throw
160
165
  throw new MissingInputError(name, spec.message);
161
166
  }
162
167
  }