Npm exec implementation for #3313

Hi

I've extracted the exec code from the lifecycle.js and added an npm exec command to run scripts in the package context. In part it fixes #3313. In reality I couldn't eliminate lifecycle at all, because it contains some specific logic like hooks.

I know that @grncdr works on the same task, but it happened that I've made this work too and I'll be happy if it will be useful.

I'm ready to fix things if needed.