|
2 | 2 |
|
3 | 3 | const BB = require('bluebird')
|
4 | 4 |
|
5 |
| -const npa = require('npm-package-arg') |
6 |
| -const workerFarm = require('worker-farm') |
7 |
| - |
8 | 5 | const extractionWorker = require('./worker.js')
|
| 6 | +const figgyPudding = require('figgy-pudding') |
| 7 | +const npa = require('npm-package-arg') |
9 | 8 | const WORKER_PATH = require.resolve('./worker.js')
|
| 9 | +let workerFarm |
| 10 | + |
| 11 | +// Broken for now, cause too many issues on some systems. |
| 12 | +const ENABLE_WORKERS = false |
| 13 | + |
| 14 | +const ExtractOpts = figgyPudding({ |
| 15 | + log: {} |
| 16 | +}) |
10 | 17 |
|
11 | 18 | module.exports = {
|
12 | 19 | startWorkers () {
|
13 |
| - this._workers = workerFarm({ |
14 |
| - maxConcurrentCallsPerWorker: 20, |
15 |
| - maxRetries: 1 |
16 |
| - }, WORKER_PATH) |
| 20 | + if (ENABLE_WORKERS) { |
| 21 | + if (!workerFarm) { workerFarm = require('worker-farm') } |
| 22 | + this._workers = workerFarm({ |
| 23 | + maxConcurrentCallsPerWorker: 20, |
| 24 | + maxRetries: 1 |
| 25 | + }, WORKER_PATH) |
| 26 | + } |
17 | 27 | },
|
18 | 28 |
|
19 | 29 | stopWorkers () {
|
20 |
| - workerFarm.end(this._workers) |
| 30 | + if (ENABLE_WORKERS) { |
| 31 | + if (!workerFarm) { workerFarm = require('worker-farm') } |
| 32 | + workerFarm.end(this._workers) |
| 33 | + } |
21 | 34 | },
|
22 | 35 |
|
23 |
| - child (name, child, childPath, config, opts) { |
| 36 | + child (name, child, childPath, opts) { |
| 37 | + opts = ExtractOpts(opts) |
24 | 38 | const spec = npa.resolve(name, child.version)
|
25 |
| - const additionalToPacoteOpts = {} |
26 |
| - if (typeof opts.dirPacker !== 'undefined') { |
27 |
| - additionalToPacoteOpts.dirPacker = opts.dirPacker |
28 |
| - } |
29 |
| - const childOpts = config.toPacote(Object.assign({ |
| 39 | + let childOpts = opts.concat({ |
30 | 40 | integrity: child.integrity,
|
31 | 41 | resolved: child.resolved
|
32 |
| - }, additionalToPacoteOpts)) |
| 42 | + }) |
33 | 43 | const args = [spec, childPath, childOpts]
|
34 | 44 | return BB.fromNode((cb) => {
|
35 | 45 | let launcher = extractionWorker
|
36 | 46 | let msg = args
|
37 | 47 | const spec = typeof args[0] === 'string' ? npa(args[0]) : args[0]
|
38 |
| - childOpts.loglevel = opts.log.level |
39 |
| - if (spec.registry || spec.type === 'remote') { |
| 48 | + if (ENABLE_WORKERS && (spec.registry || spec.type === 'remote')) { |
| 49 | + if (!workerFarm) { workerFarm = require('worker-farm') } |
40 | 50 | // We can't serialize these options
|
41 |
| - childOpts.config = null |
42 |
| - childOpts.log = null |
43 |
| - childOpts.dirPacker = null |
| 51 | + childOpts = childOpts.concat({ |
| 52 | + log: null, |
| 53 | + dirPacker: null |
| 54 | + }) |
44 | 55 | // workers will run things in parallel!
|
45 | 56 | launcher = this._workers
|
46 | 57 | try {
|
|
0 commit comments