Skip to content

Не работает $function с параметрами после build #1

@alexeyten

Description

@alexeyten

После build-а функция уже с параметрами и получается вложенный массив.
{ '$function': [ [ 'test', { data: 42 } ], { ENV: 'test' } ] }. Надо склеивать параметры функции или обрабатывать вложенный массив.

'use strict';

const buildConfig = require('dollar-config/build');
const DollarConfig = require('dollar-config');

const source = {
    func: { $function: [ 'test', { data: 42 } ] }
};

const functions = {
    test: (params) => params.data
};

const good = new DollarConfig(source, { functions });
console.log('GOOD', good.get('func', {})); // => GOOD 42

const builded = buildConfig(source, { ENV: 'test' });
const bad = new DollarConfig(builded, { functions });

console.log('BAD', bad.get('func', {})); // Кидает ошибку
/*
.../node_modules/dollar-config/index.js:189
    path = path.split('.');
                ^
    TypeError: path.split is not a function
    at get (.../node_modules/dollar-config/index.js:189:17)
    at Object.$function (.../node_modules/dollar-config/index.js:44:16)
    at Config._resolve (.../node_modules/dollar-config/index.js:110:44)
    at Config.get (.../node_modules/dollar-config/index.js:80:30)
    at ...
*/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions