Refactor buildCommandPath and add npm run scripts