feat: limit concurrency of root build script
Should fixes https://xcp-ng.org/forum/post/54567
This commit is contained in:
parent
7a4cec5093
commit
08298d3284
@ -3,6 +3,7 @@
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/eslint-parser": "^7.13.8",
|
||||
"@babel/register": "^7.0.0",
|
||||
"@vates/async-each": "1.0.0",
|
||||
"babel-jest": "^29.0.3",
|
||||
"benchmark": "^2.1.4",
|
||||
"deptree": "^1.0.0",
|
||||
@ -16,6 +17,7 @@
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"eslint-plugin-react": "^7.21.5",
|
||||
"exec-promise": "^0.7.0",
|
||||
"getopts": "^2.3.0",
|
||||
"globby": "^13.1.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"husky": "^4.2.5",
|
||||
@ -77,7 +79,7 @@
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "scripts/run-script.js --parallel build",
|
||||
"build": "scripts/run-script.js --parallel --concurrency 2 build",
|
||||
"ci": "yarn && yarn build && yarn test-integration",
|
||||
"clean": "scripts/run-script.js --parallel clean",
|
||||
"dev": "scripts/run-script.js --parallel dev",
|
||||
|
@ -5,6 +5,7 @@
|
||||
const { delimiter } = require('path')
|
||||
const { forEach, fromEvent } = require('promise-toolbox')
|
||||
const { spawn } = require('child_process')
|
||||
const getopts = require('getopts')
|
||||
|
||||
const { getPackages } = require('./utils')
|
||||
|
||||
@ -14,12 +15,19 @@ const { env } = process
|
||||
//
|
||||
// TODO: https://docs.npmjs.com/misc/scripts#environment
|
||||
require('exec-promise')(args => {
|
||||
const parallel = args[0] === '--parallel'
|
||||
const script = args[parallel ? 1 : 0]
|
||||
const {
|
||||
concurrency,
|
||||
parallel,
|
||||
_: [script],
|
||||
} = getopts(args, {
|
||||
boolean: ['parallel'],
|
||||
string: ['concurrency'],
|
||||
})
|
||||
|
||||
let errors = 0
|
||||
return getPackages(true)
|
||||
[parallel ? 'map' : 'forEach'](({ dir, name, package: { scripts } }) => {
|
||||
[parallel ? 'map' : 'forEach'](
|
||||
({ dir, name, package: { scripts } }) => {
|
||||
if (scripts == null) {
|
||||
return
|
||||
}
|
||||
@ -44,7 +52,9 @@ require('exec-promise')(args => {
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
{ concurrency: concurrency ? Number(concurrency) : undefined }
|
||||
)
|
||||
.then(() => {
|
||||
if (errors !== 0) {
|
||||
throw errors
|
||||
|
@ -1,5 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const { asyncEach } = require('@vates/async-each')
|
||||
const { forEach, fromCallback } = require('promise-toolbox')
|
||||
const { join } = require('path')
|
||||
const fs = require('fs')
|
||||
@ -34,7 +35,7 @@ exports.getPackages = (readPackageJson = false) => {
|
||||
: pkgs
|
||||
})
|
||||
p.forEach = fn => p.then(pkgs => forEach.call(pkgs, fn))
|
||||
p.map = fn => p.then(pkgs => Promise.all(pkgs.map(fn))).then(noop)
|
||||
p.map = (fn, opts) => p.then(pkgs => asyncEach(pkgs, fn, opts)).then(noop)
|
||||
return p
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user