azproduction / lmd

LMD - JavaScript Module-Assembler for building better web applications :warning: Project is no longer supported :warning:
http://azproduction.ru/lmd/
MIT License
449 stars 27 forks source link

glob works not as expected #142

Closed noway closed 11 years ago

noway commented 11 years ago

* (asterisk) in module name always returns file basename, despite of matching pattern. For example:

{
    "root": "../src",
    "output": "../scripts/index.lmd.js",
    "www_root": "../",

    "modules": {
        "main": "js/main.js",

        "*-tpl": "tpls/*.min.html",
    },

    "main": "main",
}

would declare this modules

template-name.min-tpl
some-template-name.min-tpl
another-template-name.min-tpl

instead of

template-name-tpl
some-template-name-tpl
another-template-name-tpl

That behavior hardcoded here: https://github.com/azproduction/lmd/blob/master/lib/lmd_common.js#L922

Currently i fix that with this workaround:

"modules": {
    "<%= file.replace('.min', '') %>-tpl": "tpls/*.min.html",
}
azproduction commented 11 years ago

* is just shortcut for file

var moduleNameTemplate = template(moduleName.replace('*', '<%= file %>'));

I know that it is not obvious, but now I can't change that behaviour. It might break backward capability.

noway commented 11 years ago

Maybe introduce new variable that contains match result? In order to be able do this:

"modules": {
    "<%= match %>-tpl": "tpls/*.min.html",
}
azproduction commented 11 years ago

Value "tpls/.min.html" is glob-pattern, so it can be like this "tpls//pewpew/.min.html" or this "tpls//compiled.html" And what "match" suppose to be a in this case I do not know.

noway commented 11 years ago

Oh, right. Maybe make array, like what /regexp/.exec() return? But this start look too complex.

azproduction commented 11 years ago

Yes, Array is too complex.