update Cakefile to log stderr
refactor Cakefile, extract function runscript()