45 lines
1.2 KiB
JavaScript
Executable file
45 lines
1.2 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
"use strict"
|
|
|
|
var o = require("../ospec")
|
|
var path = require("path")
|
|
var glob = require("glob")
|
|
|
|
|
|
function parseArgs(argv) {
|
|
argv = ["--globs"].concat(argv.slice(2))
|
|
var args = {}
|
|
var name
|
|
argv.forEach(function(arg) {
|
|
if ((/^--/).test(arg)) {
|
|
name = arg.substr(2)
|
|
args[name] = args[name] || []
|
|
} else {
|
|
args[name].push(arg)
|
|
}
|
|
})
|
|
return args
|
|
}
|
|
|
|
|
|
var args = parseArgs(process.argv)
|
|
var globList = args.globs && args.globs.length ? args.globs : ["**/tests/**/*.js"]
|
|
var ignore = ["**/node_modules/**"].concat(args.ignore || [])
|
|
var cwd = process.cwd()
|
|
|
|
if (args.require) {
|
|
args.require.forEach(function(module) {
|
|
// eslint-disable-next-line global-require
|
|
if (module) require(require.resolve(module, {paths: [cwd]}))
|
|
})
|
|
}
|
|
|
|
var pending = globList.length
|
|
globList.forEach(function(globPattern) {
|
|
glob(globPattern, {ignore: ignore})
|
|
.on("match", function(fileName) { require(path.join(cwd, fileName)) }) // eslint-disable-line global-require
|
|
.on("error", function(e) { console.error(e) })
|
|
.on("end", function() { if (--pending === 0) o.run()})
|
|
});
|
|
|
|
process.on("unhandledRejection", function(e) { console.error("Uncaught (in promise) " + e.stack) })
|