diff options
| author | Christophe Porteneuve <[email protected]> | 2013-11-08 20:02:29 +0100 |
|---|---|---|
| committer | Christophe Porteneuve <[email protected]> | 2013-11-08 20:02:29 +0100 |
| commit | b12c8cf5f0bc11486e2b064a834ee9ff81adb0a3 (patch) | |
| tree | c9d4c6e350d912883719ae5b4a455111ffeaa079 | |
| parent | a49eaa7f533bb7c3338d7864e3d118d43ede861e (diff) | |
| download | node-coveralls-b12c8cf5f0bc11486e2b064a834ee9ff81adb0a3.tar.xz node-coveralls-b12c8cf5f0bc11486e2b064a834ee9ff81adb0a3.zip | |
Ah, right, ES5 has String#trim(), keep forgetting that…
| -rw-r--r-- | lib/detectLocalGit.js | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/detectLocalGit.js b/lib/detectLocalGit.js index 2d0fba0..4fd8d1b 100644 --- a/lib/detectLocalGit.js +++ b/lib/detectLocalGit.js @@ -16,15 +16,11 @@ module.exports = function detectLocalGit(knownCommit, knownBranch) { if ('/' === dir) return; - var head = strip(fs.readFileSync(path.join(dir, '.git', 'HEAD'), 'utf-8')); + var head = fs.readFileSync(path.join(dir, '.git', 'HEAD'), 'utf-8').trim(); var branch = (head.match(REGEX_BRANCH) || [])[1]; if (!branch) return { git_commit: head }; - var commit = strip(fs.readFileSync(path.join(dir, '.git', 'refs', 'heads', branch), 'utf-8')); + var commit = fs.readFileSync(path.join(dir, '.git', 'refs', 'heads', branch), 'utf-8').trim(); return { git_commit: commit, git_branch: branch }; }; - -function strip(str) { - return (str || '').replace(/^\s+|\s+$/g, ''); -} |
