Skip to content

Commit

Permalink
Merge branch 'master' into stubImplFocusBug
Browse files Browse the repository at this point in the history
  • Loading branch information
riju91 committed Mar 2, 2018
2 parents b28222e + 2dee29a commit e8d4846
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -28,6 +28,7 @@
"escodegen": "^1.9.0",
"esprima": "^4.0.0",
"estraverse": "^4.2.0",
"klaw-sync": "^3.0.2",
"micromatch": "^2.3.11",
"protobufjs": "~6.8.0",
"q": "^1.5.0",
Expand Down
40 changes: 18 additions & 22 deletions src/file-util.js
@@ -1,33 +1,29 @@
var fs = require("fs");
var path = require("path");
var klawSync = require("klaw-sync");
var micromatch = require("micromatch");

var ignoredDirs = [".gauge", ".git", "node_modules", "reports"];


function shouldIgnore(item) {
return !ignoredDirs.includes(path.basename(item.path));
}

exports = module.exports;

exports.getListOfFilesFromPath = function(basePath, conf) {
if(!fs.existsSync(basePath)) {
exports.getListOfFilesFromPath = function (basePath, conf) {
if (!fs.existsSync(basePath)) {
return [];
}
function walk(dir){
var result = [];

fs.readdirSync(dir).forEach(function(fileName){
var filePath = path.join(dir, fileName);
var stat = fs.statSync(filePath);
if (stat && !stat.isDirectory()) {
result.push(filePath);
}else{
var dirContent = walk(filePath);
result = result.concat(dirContent);
}
});
return result;
}
var result = walk(basePath);
result = micromatch(result, conf.testMatch);
return result;
var options = { filter: shouldIgnore, noRecurseOnFailedFilter: true };
var results = klawSync(basePath, options).map(function (item) {
return item.path;
});
results = micromatch(results, conf.testMatch);
return results;
};

exports.isSameFilePath = function(filePath1, filePath2) {
exports.isSameFilePath = function (filePath1, filePath2) {
return path.relative(filePath1, filePath2) === "";
};
};

0 comments on commit e8d4846

Please sign in to comment.