Created
August 17, 2015 12:53
-
-
Save cesarandreu/6583151d18cd85ab7d6c to your computer and use it in GitHub Desktop.
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
'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