[Pkg-javascript-commits] [node-coveralls] 135/332: Windows compat fixes

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit ab1c7aeda0359fb174e4dbfdb7e117cc029eb329
Author: Gerard Escalante <gerard at saygo.ca>
Date:   Tue Feb 11 11:10:34 2014 +0900

    Windows compat fixes
    
    Changed usage of '/' as root dir. Stopped tests from wiping out
    environment.
---
 lib/convertLcovToCoveralls.js | 10 ++--------
 lib/detectLocalGit.js         |  4 ++--
 package.json                  |  2 +-
 test/fetchGitData.js          |  3 ---
 test/getOptions.js            |  4 ++--
 5 files changed, 7 insertions(+), 16 deletions(-)

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();
diff --git a/package.json b/package.json
index b927e96..16aa2e9 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
   "dependencies": {
     "yaml": "0.2.3",
     "request": "2.16.2",
-    "lcov-parse": "0.0.4",
+    "lcov-parse": "0.0.6",
     "log-driver": "1.2.1"
   },
   "devDependencies": {
diff --git a/test/fetchGitData.js b/test/fetchGitData.js
index 9c00828..3b8b0fe 100644
--- a/test/fetchGitData.js
+++ b/test/fetchGitData.js
@@ -3,9 +3,6 @@ var fetchGitData = require('../lib/fetchGitData');
 var getOptions = require('../index').getOptions;
 
 describe("fetchGitData", function(){
-  beforeEach(function(){
-    process.env = {};
-  });
   it("should throw an error when no data is passed", function() {
     fetchGitData.should.throw(/fetchGitData requires a callback/);
   });
diff --git a/test/getOptions.js b/test/getOptions.js
index f9b2494..9e844ec 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -301,7 +301,7 @@ function ensureLocalGitContext(options) {
   var fs = require('fs');
 
   var baseDir = process.cwd(), dir = baseDir, gitDir;
-  while ('/' !== dir) {
+  while (path.resolve('/') !== dir) {
     gitDir = path.join(dir, '.git');
     var existsSync = fs.existsSync || path.existsSync;
     if (existsSync(path.join(gitDir, 'HEAD')))
@@ -311,7 +311,7 @@ function ensureLocalGitContext(options) {
   }
 
   options = options || {};
-  var synthetic = '/' === dir;
+  var synthetic = path.resolve('/') === dir;
   var gitHead, content, branch, id, wrapUp = function() {};
 
   if (synthetic) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list