fix(ospec): Only run o.run() once (#2142)

This commit is contained in:
Már Örlygsson 2018-05-06 23:46:56 +00:00 committed by Pierre-Yves Gérardy
parent cfaa377c1e
commit ceabe993a3

View file

@ -27,11 +27,17 @@ const globList = args.globs && args.globs.length ? args.globs : ["**/tests/**/*.
const ignore = ["**/node_modules/**"].concat(args.ignore||[])
const cwd = process.cwd()
let pending = globList.length
globList.forEach((globPattern) => {
glob(globPattern, {ignore})
.on("match", (fileName) => { require(path.join(cwd, fileName)) }) // eslint-disable-line global-require
.on("error", (e) => console.error(e))
.on("end", o.run)
.on("end", () => {
pending--
if (pending === 0) {
o.run()
}
})
});
process.on("unhandledRejection", (e) => { console.log("Uncaught (in promise) " + e.stack) })