@@ -3,12 +3,12 @@ import type { CommandFileObject, ReloadOptions } from '../../typings';
33
44import { toFileURL } from '../../utils/resolve-file-url' ;
55import { getFilePaths } from '../../utils/get-paths' ;
6+ import { clone } from '../../utils/clone' ;
67
78import loadCommandsWithRest from './functions/loadCommandsWithRest' ;
89import registerCommands from './functions/registerCommands' ;
9- import builtInValidations from './validations' ;
10+ import builtInValidationsFunctions from './validations' ;
1011import colors from '../../utils/colors' ;
11- import { clone } from '../../utils/clone' ;
1212
1313/**
1414 * A handler for client application commands.
@@ -27,7 +27,7 @@ export class CommandHandler {
2727 async init ( ) {
2828 await this . #buildCommands( ) ;
2929
30- this . #buildValidations ( ) ;
30+ this . #buildBuiltInValidations ( ) ;
3131
3232 const devOnlyCommands = this . #data. commands . filter ( ( cmd ) => cmd . options ?. devOnly ) ;
3333
@@ -150,9 +150,9 @@ export class CommandHandler {
150150 }
151151 }
152152
153- #buildValidations ( ) {
154- for ( const validationFunction of builtInValidations ) {
155- this . #data. builtInValidations . push ( validationFunction ) ;
153+ #buildBuiltInValidations ( ) {
154+ for ( const builtInValidationFunction of builtInValidationsFunctions ) {
155+ this . #data. builtInValidations . push ( builtInValidationFunction ) ;
156156 }
157157 }
158158
@@ -175,7 +175,7 @@ export class CommandHandler {
175175
176176 const { data, options, run, autocompleteRun, ...rest } = targetCommand ;
177177
178- // skip if autocomplete handler is not defined
178+ // Skip if autocomplete handler is not defined
179179 if ( isAutocomplete && ! autocompleteRun ) return ;
180180
181181 const commandObj = {
@@ -239,9 +239,15 @@ export class CommandHandler {
239239 }
240240
241241 async reloadCommands ( type ?: ReloadOptions ) {
242+ if ( ! this . #data. commandsPath ) {
243+ throw new Error (
244+ 'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.' ,
245+ ) ;
246+ }
247+
242248 this . #data. commands = [ ] ;
243249
244- // Rebuild commands tree
250+ // Re-build commands tree
245251 await this . #buildCommands( ) ;
246252
247253 if ( this . #data. bulkRegister ) {
@@ -262,6 +268,4 @@ export class CommandHandler {
262268 } ) ;
263269 }
264270 }
265-
266- async useUpdatedValidations ( ) { }
267271}
0 commit comments