Skip to content

Hooks

shipped 1.0.0

Executable shell scripts in cwp/hooks/, run with the project root as the working directory and a documented set of environment variables: CWP_ENV, CWP_PROJECT, CWP_LOCAL_URL, CWP_REMOTE_URL, CWP_REMOTE_APP, CWP_WP_CONTENT.

HookRunsOn a non-zero exit
pre-push.shbefore cwp push and cwp deployaborts: exit 5, nothing transfers
post-pull.shafter cwp db pull and cwp media pullwarns; the pull already happened
post-deploy.shafter cwp deploywarns; the files are already on the remote

Only pre-push can stop anything. It runs before the one operation in this tool that can damage a live site. The other two run after the fact, so failing the whole command would misreport what happened.

Hooks are also the answer to “how do I extend cwp”. There is no plugin system and there is not going to be one. A shell script you write, in your shell, needs no interface, and no cwp release can break it.

cwp init generates all three as commented no-op samples. cwp reports a hook that exists but is not executable with a chmod +x hint rather than skipping it silently. The rule is the same as everywhere else here: a mechanism that quietly did not run is the defect, not the inconvenience.

No hook runs during a dry run. A dry run that executed your script would be describing a different command from the one you are about to type.