Run your commands around axx's
A hook runs a command of your project’s before or after one of axx’s. List hooks in axx.yaml, under hooks.commands:
hooks: commands: # Write the schema the parcels seeds are checked against, from the migrations. - before: fixtures generate command: ./scripts/write-schema.sh # Send the run's report to the depot team, whether the run passed or not. - after: run shell: true command: ./scripts/send-report.sh reports/report.htmlbeforeorafternames the axx command, by its words afteraxx:fixtures generate,run,validate. Every command has hooks butpack,init,upgrade,installandversion, which manage axx and its packs.commandis what the hook runs, from the directory ofaxx.yaml: a string, split into words without a shell, or a list. Withshell: true, it runs through/bin/sh -c(cmd /Con Windows).- A hook that fails before its command stops it. The command doesn’t run, and the error says which hook failed and how.
- A hook after its command runs whether the command succeeded or failed. When it fails, a command that succeeded fails too; after a command that failed, it is a warning.
- A hook knows what it runs around:
AXX_COMMANDholds the command’s words (fixtures generate), and an after hook’sAXX_COMMAND_FAILEDistrueorfalse. It runs with the rest of the environment axx has. - A hook before
axx runcan tell the scenarios properties, as a service does: linesname=valuein the file$AXX_PROPERTIESnames, which they read as${sys:name}(Run beside your own stack). - Its output goes to axx’s stderr, so the command’s own output, its
--jsonanswer included, stays as it is. - Several hooks of one command run in the order
axx.yamllists them.
A hook that names a command axx has not got stops every command that has hooks, so a typo can’t go unnoticed. axx doctor still runs: it lists the project’s hooks, and says which one is wrong.
Hooks of packs
Section titled “Hooks of packs”A pack can run hooks of its own around axx’s commands. They run around those of axx.yaml: a pack’s before hooks first, its after hooks last. axx doctor lists them with the others. To write one, see Run something before or after a command.