From ab1c7aeda0359fb174e4dbfdb7e117cc029eb329 Mon Sep 17 00:00:00 2001 From: Gerard Escalante Date: Tue, 11 Feb 2014 11:10:34 +0900 Subject: Windows compat fixes Changed usage of '/' as root dir. Stopped tests from wiping out environment. --- lib/convertLcovToCoveralls.js | 10 ++-------- lib/detectLocalGit.js | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js index 15bf962..b73863a 100644 --- a/lib/convertLcovToCoveralls.js +++ b/lib/convertLcovToCoveralls.js @@ -13,11 +13,7 @@ var detailsToCoverage = function(length, details){ }; var convertLcovFileObject = function(file, filepath){ - if (file.file[0] !== '/'){ - filepath = path.join(filepath, file.file); - } else { - filepath = file.file; - } + filepath = path.resolve(filepath, file.file); var source = fs.readFileSync(filepath, 'utf8'); var lines = source.split("\n"); var coverage = detailsToCoverage(lines.length, file.lines.details); @@ -29,9 +25,7 @@ var convertLcovFileObject = function(file, filepath){ var convertLcovToCoveralls = function(input, options, cb){ var filepath = options.filepath || ''; logger.debug("in: ", filepath); - if (filepath[0] !== '/'){ - filepath = path.join(process.cwd(), filepath); - } + filepath = path.resolve(process.cwd(), filepath); lcovParse(input, function(err, parsed){ if (err){ logger.error("error from lcovParse: ", err); diff --git a/lib/detectLocalGit.js b/lib/detectLocalGit.js index 3d381db..302cd44 100644 --- a/lib/detectLocalGit.js +++ b/lib/detectLocalGit.js @@ -5,7 +5,7 @@ var REGEX_BRANCH = /^ref: refs\/heads\/(\w+)$/; module.exports = function detectLocalGit(knownCommit, knownBranch) { var dir = process.cwd(), gitDir; - while ('/' !== dir) { + while (path.resolve('/') !== dir) { gitDir = path.join(dir, '.git'); var existsSync = fs.existsSync || path.existsSync; if (existsSync(path.join(gitDir, 'HEAD'))) @@ -14,7 +14,7 @@ module.exports = function detectLocalGit(knownCommit, knownBranch) { dir = path.dirname(dir); } - if ('/' === dir) + if (path.resolve('/') === dir) return; var head = fs.readFileSync(path.join(dir, '.git', 'HEAD'), 'utf-8').trim(); -- cgit v1.2.3