mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
47 lines
1.1 KiB
JavaScript
Executable File
47 lines
1.1 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
var fs = require("fs")
|
|
var path = require("path")
|
|
|
|
var o = require("../ospec")
|
|
|
|
function traverseDirectory(pathname, callback) {
|
|
pathname = pathname.replace(/\\/g, "/")
|
|
return new Promise(function(resolve, reject) {
|
|
fs.lstat(pathname, function(err, stat) {
|
|
if (err) reject(err)
|
|
if (stat && stat.isDirectory()) {
|
|
fs.readdir(pathname, function(err, pathnames) {
|
|
if (err) reject(err)
|
|
var promises = []
|
|
for (var i = 0; i < pathnames.length; i++) {
|
|
if (pathnames[i] === "node_modules") continue
|
|
pathnames[i] = path.join(pathname, pathnames[i])
|
|
promises.push(traverseDirectory(pathnames[i], callback))
|
|
}
|
|
callback(pathname, stat, pathnames)
|
|
resolve(Promise.all(promises))
|
|
})
|
|
}
|
|
else {
|
|
callback(pathname, stat)
|
|
resolve(pathname)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
traverseDirectory(".", function(pathname, stat, children) {
|
|
if (pathname.match(/(?:^|\/)tests\/.*\.js$/)) {
|
|
require(path.normalize(process.cwd()) + "/" + pathname)
|
|
}
|
|
})
|
|
.then(o.run)
|
|
.catch(function(e) {
|
|
console.log(e.stack)
|
|
})
|
|
|
|
process.on("unhandledRejection", function(e) {
|
|
console.log("Uncaught (in promise) " + e.stack)
|
|
})
|