feat: cron (#34)

This commit is contained in:
Julien Fontanet
2018-02-01 11:28:16 +01:00
committed by GitHub
parent ff2c69102d
commit 348bc16d6d
13 changed files with 673 additions and 11 deletions

View File

@@ -1,16 +1,25 @@
const { forEach, fromCallback } = require('promise-toolbox')
const fs = require('fs')
const PKGS_DIR = `${__dirname}/../packages`
const ROOT_DIR = `${__dirname}/..`
const _getPackages = scope => {
const inScope = scope !== undefined
const dir = `${ROOT_DIR}/${inScope ? scope : 'packages'}`
return fromCallback(cb => fs.readdir(dir, cb)).then(names =>
names.map(name => ({
dir: `${dir}/${name}`,
name: inScope ? `${scope}/${name}` : name,
}))
)
}
exports.getPackages = (readPackageJson = false) => {
const p = fromCallback(cb =>
fs.readdir(PKGS_DIR, cb)
).then(names => {
const pkgs = names.map(name => ({
dir: `${PKGS_DIR}/${name}`,
name,
}))
const p = Promise.all([
_getPackages(),
_getPackages('@xen-orchestra'),
]).then(pkgs => {
pkgs = [].concat(...pkgs) // flatten
return readPackageJson
? Promise.all(pkgs.map(pkg =>
readFile(`${pkg.dir}/package.json`).then(data => {