Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue #2. Also changed the default config file name from myriad…
…-cucumber.js to MyriadCucumberfile.js
- Loading branch information
Showing
4 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,50 @@ | ||
var FS = require('fs'); | ||
var Glob = require('glob'); | ||
var Path = require('path'); | ||
var Async = require('async'); | ||
var Debug = require('debug')('myriad-cucumber') | ||
|
||
var FeatureFinder = module.exports; | ||
|
||
FeatureFinder.find = function(options, callback) { | ||
var globPatterns = []; | ||
Async.map( | ||
options.features, | ||
function(feature, callback) { | ||
FS.stat(feature, function(err, stats) { | ||
if (err) { | ||
callback(err); | ||
} | ||
else { | ||
if (stats.isDirectory()) { | ||
callback(null, Path.join(feature, '**/*.feature')); | ||
} | ||
else { | ||
callback(null, feature); | ||
} | ||
} | ||
}); | ||
}, | ||
function(err, globPatterns) { | ||
if (err) { | ||
callback({ message: "Failed to find the features", innerError: err }); | ||
} | ||
else { | ||
if (globPatterns.length > 1) { | ||
globPatterns = '{' + globPatterns.join(',') + '}'; | ||
} | ||
else { | ||
globPatterns = globPatterns[0]; | ||
} | ||
|
||
options.features.forEach(function(featuresDir) { | ||
globPatterns.push(Path.join(featuresDir, '**/*.feature')); | ||
}) | ||
|
||
if (globPatterns.length > 1) { | ||
globPatterns = '{' + globPatterns.join(',') + '}'; | ||
} | ||
else { | ||
globPatterns = globPatterns[0]; | ||
} | ||
|
||
Glob(globPatterns, { strict: true }, function(err, featureFiles) { | ||
if (err) { | ||
callback(err); | ||
} | ||
else { | ||
callback(null, featureFiles); | ||
Glob(globPatterns, { strict: true }, function(err, featureFiles) { | ||
if (err) { | ||
callback({ message: "Failed to find the features", innerError: err }); | ||
} | ||
else { | ||
callback(null, featureFiles); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters