Migrate external commands to internal

Need to extract a variable for HOMEBREW_LIBRARY_PATH.join("cmd", cmd) rather than do it 3 times.