Skip to content

PluginAppHooksDefinition

Хуки жизненного цикла приложения.

Свойства

НаименованиеТипОбязательное
afterInitFunctionНет
beforeExitFunctionНет
beforeCommandRunFunctionНет
afterCommandRunFunctionНет

Описание свойств

afterInit

Тип: (params: { profilePath: string }) => Promise<void>

Обязательное: Нет

Вызывается после инициализации приложения.

Параметры:

  • profilePath — путь к профилю

Пример:

typescript
{
  afterInit: async ({ profilePath }) => {
    console.log("Application initialized")
    console.log("Profile path:", profilePath)
  }
}

beforeExit

Тип: (reason?: string) => Promise<void>

Обязательное: Нет

Вызывается перед выходом из приложения.

Параметры:

  • reason — опциональная причина выхода

Пример:

typescript
{
  beforeExit: async reason => {
    console.log("Application exiting")
    if (reason) {
      console.log("Reason:", reason)
    }
  }
}

beforeCommandRun

Тип: (params: { command: string; args: unknown[] }) => Promise<void>

Обязательное: Нет

Вызывается перед выполнением команды.

Параметры:

  • command — имя команды
  • args — аргументы команды

Пример:

typescript
{
  beforeCommandRun: async ({ command, args }) => {
    console.log("Executing command:", command)
    console.log("Arguments:", args)
  }
}

afterCommandRun

Тип: (params: { command: string; args: unknown[] }) => Promise<void>

Обязательное: Нет

Вызывается после выполнения команды.

Параметры:

  • command — имя команды
  • args — аргументы команды

Пример:

typescript
{
  afterCommandRun: async ({ command, args }) => {
    console.log("Command completed:", command)
    console.log("Arguments:", args)
  }
}