Skip to content

Commit

Permalink
Fixes issue #2. Also changed the default config file name from myriad…
Browse files Browse the repository at this point in the history
…-cucumber.js to MyriadCucumberfile.js
  • Loading branch information
simondean committed Jul 1, 2013
1 parent 6d44292 commit 46e5c3e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 25 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -35,12 +35,11 @@ $ npm install --dev

### Config

You need to add a myriad-cucumber.js confg file to the your test codebase:
You need to add a MyriadCucumberfile.js confg file to the your test codebase:

``` javascript
module.exports = {
package: '.',
features: ['features'],
profiles: {
default: {
bin: 'node_modules/.bin/cucumber-js',
Expand Down
7 changes: 4 additions & 3 deletions bin/myriad-cucumber
Expand Up @@ -17,14 +17,14 @@ function exit(code) {
};

var optimist = Optimist
.usage('Usage: $0 options')
.usage('Usage: $0 options [FILE|DIR]+')
.options('h', {
alias: 'help',
describe: 'Displays this help message'
})
.options('c', {
alias: 'config',
default: './myriad-cucumber.js',
default: './MyriadCucumberfile.js',
describe: 'Path to the config file'
})
.options('o', {
Expand Down Expand Up @@ -58,7 +58,8 @@ else {
configFile: argv['config'],
out: argv.out,
localPackage: argv['local-package'],
workers: argv.workers
workers: argv.workers,
features: argv._
};

Debug('Options ' + JSON.stringify(options));
Expand Down
59 changes: 40 additions & 19 deletions lib/feature_finder.js
@@ -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);
}
});
}
}
});
);
}
2 changes: 1 addition & 1 deletion lib/myriad_cucumber.js
Expand Up @@ -15,7 +15,7 @@ var MyriadCucumber = function(options) {
var config = require(Path.resolve(configFile));

options.localPackage = options.myriadServerUrl ? false : options.localPackage;
options.features = config.features;
options.features = options.features;
options.package = config.package;
options.profiles = config.profiles;

Expand Down

0 comments on commit 46e5c3e

Please sign in to comment.