|
1 | 1 | const yaml = require('js-yaml');
|
2 | 2 | const fs = require('fs');
|
| 3 | +const stream = require('stream'); |
3 | 4 |
|
4 | 5 | const secrets = require('./lib/secrets');
|
5 | 6 | const volumes = require('./lib/volumes');
|
@@ -42,20 +43,26 @@ class Compose {
|
42 | 43 | }
|
43 | 44 |
|
44 | 45 | async pull(serviceN, options) {
|
| 46 | + options = options || {}; |
45 | 47 | var streams = [];
|
46 | 48 | var serviceNames = (serviceN === undefined || serviceN === null) ? tools.sortServices(this.recipe) : [serviceN];
|
47 | 49 | for (var serviceName of serviceNames) {
|
48 | 50 | var service = this.recipe.services[serviceName];
|
49 | 51 | try {
|
50 |
| - var stream = await this.docker.pull(service.image); |
51 |
| - streams.push(stream); |
52 |
| - if (options && options.verbose) { |
53 |
| - stream.pipe(process.stdout); |
54 |
| - } else { |
55 |
| - stream.pipe(new require('stream').PassThrough()); |
| 52 | + var streami = await this.docker.pull(service.image); |
| 53 | + streams.push(streami); |
| 54 | + |
| 55 | + if (options.verbose === true) { |
| 56 | + streami.pipe(process.stdout); |
56 | 57 | }
|
57 |
| - if (options === undefined || (options && options.streams !== true)) { |
58 |
| - await new Promise(fulfill => stream.once('end', fulfill)); |
| 58 | + |
| 59 | + if (options.streams !== true) { |
| 60 | + if (options.verbose === true) { |
| 61 | + streami.pipe(process.stdout); |
| 62 | + } else { |
| 63 | + streami.pipe(stream.PassThrough()); |
| 64 | + } |
| 65 | + await new Promise(fulfill => streami.once('end', fulfill)); |
59 | 66 | }
|
60 | 67 | } catch (e) {
|
61 | 68 | throw e;
|
|
0 commit comments