Skip to content

Commit

Permalink
feat: separated forced transpilation from --multiprocess (#22301)
Browse files Browse the repository at this point in the history
* feat: separated forced transpilation from --multiprocess

npm commands using --multiprocess had --force added as well

* build/transpile.js fixes
  • Loading branch information
samgermain committed Apr 30, 2024
1 parent 246d24b commit 1ef9ec5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
14 changes: 10 additions & 4 deletions build/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2941,15 +2941,21 @@ class Transpiler {
}
}

function parallelizeTranspiling (exchanges, processes = undefined) {
function parallelizeTranspiling (exchanges, processes = undefined, force = false) {
const processesNum = Math.min(processes || os.cpus ().length, exchanges.length)
log.bright.green ('starting ' + processesNum + ' new processes...')
let isFirst = true
const args = [];
if (force) {
args.push ('--force')
}
for (let i = 0; i < processesNum; i ++) {
const toProcess = exchanges.filter ((_, index) => index % processesNum === i)
const args = isFirst ? [ '--force' ] : [ '--child', '--force' ]
isFirst = false
fork (process.argv[1], toProcess.concat (args))
if (isFirst) {
args.push ('--child');
isFirst = false
}
}
}

Expand Down Expand Up @@ -2984,7 +2990,7 @@ if (isMainEntry(import.meta.url)) {
} else if (errors) {
transpiler.transpileErrorHierarchy ({ tsFilename })
} else if (multiprocess) {
parallelizeTranspiling (exchangeIds)
parallelizeTranspiling (exchangeIds, undefined, force)
} else {
(async () => {
await transpiler.transpileEverything (force, child)
Expand Down
2 changes: 1 addition & 1 deletion build/transpileWS.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ if (isMainEntry(import.meta.url)) { // called directly like `node module`
transpiler.transpileWsTests ()
}
else if (multiprocess) {
parallelizeTranspiling (exchanges.ws)
parallelizeTranspiling (exchanges.ws, undefined, force)
} else {
(async () => {
await transpiler.transpileEverything (force, child)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
"force-transpile-fast": "npm run dev-force-transpile",
"dev-force-transpile": "npm run fast-force-transpileRest && npm run fast-force-transpileWs",
"force-transpileRest": "node build/transpile --force",
"fast-force-transpileRest": "node build/transpile.js --multiprocess",
"fast-force-transpileRest": "node build/transpile.js --multiprocess --force",
"force-transpileWs": "node build/transpileWS --force",
"fast-force-transpileWs": "node build/transpileWS.js --multiprocess",
"fast-force-transpileWs": "node build/transpileWS.js --multiprocess --force",
"test-js-cache": "node js/src/pro/test/base/test.Cache.js",
"test-js-orderbook": "node js/src/pro/test/base/test.OrderBook.js",
"test-python-cache": "python python/ccxt/pro/test/base/test_cache.py",
Expand Down

0 comments on commit 1ef9ec5

Please sign in to comment.