private function executeNpm($arguments, $workingDirectoryPath)
{
array_unshift($arguments, $this->npmPath());
$command = implode(' ', array_map('escapeshellarg', $arguments));
if (null !== $workingDirectoryPath) {
$previousWorkingDirectoryPath = call_user_func($this->getcwd);
call_user_func($this->chdir, $workingDirectoryPath);
}
$exitCode = $this->processExecutor->execute($command);
if (null !== $workingDirectoryPath) {
call_user_func($this->chdir, $previousWorkingDirectoryPath);
}
if (0 !== $exitCode) {
throw new NpmCommandFailedException($command);
}
}