forked from Quobject/dockerode-bluebird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (34 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// from https://github.com/d6u/Dockership/blob/master/lib/promisified/docker-promisified.js
// Added code for image
'use strict';
var Bluebird = require('bluebird');
var Docker = require('dockerode');
Bluebird.promisifyAll(Docker.prototype);
var _getContainer = Docker.prototype.getContainer;
Docker.prototype.getContainer = function () {
var container = _getContainer.apply(this, arguments);
if (!container.startAsync) {
var containerPrototype = Object.getPrototypeOf(container);
var _exec = containerPrototype.exec;
containerPrototype.exec = function (opts, cb) {
_exec.call(this, opts, function (err, exec) {
if (exec && !exec.startAsync) {
Bluebird.promisifyAll(Object.getPrototypeOf(exec));
}
cb(err, exec);
});
};
Bluebird.promisifyAll(containerPrototype);
}
return container;
};
var _getImage = Docker.prototype.getImage;
Docker.prototype.getImage = function () {
var image = _getImage.apply(this, arguments);
if (!image.getAsync) {
var imagePrototype = Object.getPrototypeOf(image);
Bluebird.promisifyAll(imagePrototype);
}
return image;
};
module.exports = Docker;