diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-04-02 07:15:18 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-04-02 07:15:18 +0300 |
commit | cd67a0db07891d20871822696c26692c8a84866a (patch) | |
tree | e7c05e86fb3b4de487cb416222fcebd17dc0ab59 /lib | |
parent | b7475936f473f029e6a027ba1b16277523747d0b (diff) |
git: don't assume stdout exists on error
When checking the remote URL for a repo, if it errors out, stdout may
not be set.
Fixes #7829.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cache/add-remote-git.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/cache/add-remote-git.js b/lib/cache/add-remote-git.js index cf0a5d4c8..333b929e9 100644 --- a/lib/cache/add-remote-git.js +++ b/lib/cache/add-remote-git.js @@ -95,10 +95,13 @@ module.exports = function addRemoteGit (uri, silent, cb) { ['config', '--get', 'remote.origin.url'], { cwd: cachedRemote, env: gitEnv() }, function (er, stdout, stderr) { - var originURL = stdout.trim() - stderr = stderr.trim() - log.verbose('addRemoteGit', 'remote.origin.url:', originURL) + var originURL + if (stdout) { + originURL = stdout.trim() + log.verbose('addRemoteGit', 'remote.origin.url:', originURL) + } + stderr = stderr.trim() if (stderr || er) { log.warn('addRemoteGit', 'resetting remote', cachedRemote, 'because of error:', stderr || er) return resetRemote(cb) |