Skip to content

Instantly share code, notes, and snippets.

@cesarandreu
Created August 17, 2015 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarandreu/6583151d18cd85ab7d6c to your computer and use it in GitHub Desktop.
Save cesarandreu/6583151d18cd85ab7d6c to your computer and use it in GitHub Desktop.
'use strict';
var assert = require('assert'),
path = require('path'),
glob = require('glob');
// If it's not a CI environment return the glob
// If it's a CI environment return the globs for the container
// Given a root path, get the full sorted list of specs using the glob
module.exports = function specList (rootPath, specGlob) {
assert(rootPath && specGlob, 'root path and spec glob are required');
var fullPath = path.join(rootPath, specGlob);
if (!process.env.CI) {
return [fullPath];
}
var CIRCLE_TOTAL = parseInt(process.env.CIRCLE_NODE_TOTAL, 10) || 1;
var CIRCLE_INDEX = parseInt(process.env.CIRCLE_NODE_INDEX, 10) || 0;
var specs = glob.sync(fullPath).sort().filter(function (file, idx) {
return idx % CIRCLE_TOTAL === CIRCLE_INDEX;
});
console.info('SPECS\n', specs);
return specs;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment