forked from Artsdatabanken/nin-data-lastejobb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kjør_alle_lastejobber.js
30 lines (28 loc) · 943 Bytes
/
kjør_alle_lastejobber.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// @flow
if (!process.env.DEBUG) process.env.DEBUG = "*"
const fs = require("fs")
const { spawnSync } = require("child_process")
const path = require("path")
const fetch = require("node-fetch")
const log = require("log-less-fancy")()
const { findFiles } = require("./lib/io")
const config = require("./config")
function exec(jsFile) {
log.info("Kjører " + jsFile)
const r = spawnSync("node", [jsFile], {
encoding: "buffer",
shell: true,
stdio: [0, 1, 2]
})
// console.log(r)
if (r.status > 0) process.exit(1)
// throw new Error(jsFile + " failed with exit code " + r.status)
log.success("Done.")
}
let files = findFiles(config.lasteScriptPath, ".js")
files = files.sort()
log.info("Fant totalt " + files.length + " skriptfiler")
log.debug("Scriptfiler: " + files)
files = files.filter(file => file.indexOf(".test") < 0)
log.info("Kjører " + files.length + " lastejobber...")
files.forEach(file => exec(file))