Skip to content

Classic resolution mode fails to resolve single parameter arrow function #30

@niyoko

Description

@niyoko

Awilix dependencies parser fails to detect factory function that is declared using arrow function with single parameter and no bracket enclosing the parameter.

How to reproduce:
Using CLASSIC resolution mode, declare following service. It will fail to parse the dependencies.

module.exports = config => {
    return {
        a: (b, c) => b
    };
}

But service below will work (notice brackets that enclose the parameter):

module.exports = (config) => {
    return {
        a: (b, c) => b
    };
}

I suspect this line causes the problem.

const DEPS_EXPR = /(\(\s*([^)]+?)\s*\)|\(\))/

Awilix version: 2.6.0
Node version: 8.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions