diff --git a/src/compose/utils.ts b/src/compose/utils.ts index 0ac8b3f9..0463fb81 100644 --- a/src/compose/utils.ts +++ b/src/compose/utils.ts @@ -19,7 +19,9 @@ import { export function camelCaseConfig(literalConfig: ConfigMap): ServiceComposeConfig { const config = _.mapKeys(literalConfig, (_v, k) => _.camelCase(k)); - if (_.isObject(config.networks)) { + // Networks can either be an object or array, but given _.isObject + // returns true for an array, we check the other way + if (!_.isArray(config.networks)) { const networksTmp = _.cloneDeep(config.networks); _.each(networksTmp, (v, k) => { config.networks[k] = _.mapKeys(v, (_v, k) => _.camelCase(k)); diff --git a/test/19-compose-utils.coffee b/test/19-compose-utils.coffee new file mode 100644 index 00000000..f60a5b17 --- /dev/null +++ b/test/19-compose-utils.coffee @@ -0,0 +1,22 @@ +require('mocha'); + +{ expect } = require('chai'); + +ComposeUtils = require('../src/compose/utils'); + +describe 'Composition utilities', -> + + it 'Should correctly camel case the configuration', -> + config = + networks: [ + 'test', + 'test2', + ] + + expect(ComposeUtils.camelCaseConfig(config)).to.deep.equal({ + networks: [ + 'test' + 'test2' + ] + }) +