From df1efecc221822595f694ba85b9a5149788fc8c2 Mon Sep 17 00:00:00 2001 From: Pedro Dias Date: Fri, 10 Mar 2017 12:49:41 +0000 Subject: [PATCH] https://github.com/apocas/dockerode/issues/343 --- lib/docker.js | 13 +++++++++++-- package.json | 2 +- test/docker.js | 21 ++++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/docker.js b/lib/docker.js index 7240c40..e5c4b86 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -21,9 +21,18 @@ var EventEmitter = require('events').EventEmitter, var Docker = function(opts) { if (!(this instanceof Docker)) return new Docker(opts); - this.modem = new Modem(opts); + var plibrary = global.Promise; + + if(opts && opts.Promise) { + plibrary = opts.Promise; + + if(Object.keys(opts).length === 1) { + opts = undefined; + } + } - this.modem.Promise = opts && opts.Promise || global.Promise; + this.modem = new Modem(opts); + this.modem.Promise = plibrary; }; /** diff --git a/package.json b/package.json index 157cab7..0705651 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dockerode", "description": "Docker Remote API module.", - "version": "2.3.4", + "version": "2.3.5", "author": "Pedro Dias ", "maintainers": [ "apocas " diff --git a/test/docker.js b/test/docker.js index d6d7342..9433c81 100644 --- a/test/docker.js +++ b/test/docker.js @@ -1,9 +1,13 @@ /*jshint -W030 */ -var expect = require('chai').expect; +var Bluebird = require('bluebird'), + expect = require('chai').expect, + Docker = require('../lib/docker'); + var docker = require('./spec_helper').docker; var dockert = require('./spec_helper').dockert; + var testImage = 'ubuntu:14.04'; var testVolume = { "Name": "tardis", @@ -13,6 +17,21 @@ var testVolume = { describe("#docker", function() { + describe("#constructors", function() { + it("should work without options", function(done) { + var d = new Docker(); + expect(d.modem.socketPath).not.to.be.null; + done(); + }); + it("should not send Promise options to docker-modem", function(done) { + var d = new Docker({ + 'Promise': Bluebird + }); + expect(d.modem.socketPath).not.to.be.null; + done(); + }); + }); + describe("#checkAuth", function() { it("should fail auth", function(done) { this.timeout(15000);