aseemk / requireDir

Node.js helper to require() directories.
MIT License
484 stars 60 forks source link

Possible conflict between directories and files with the same name #12

Closed brandonweiss closed 9 years ago

brandonweiss commented 9 years ago

I've got a directory structure that looks like this:

The output from recursively requiring is:

{ build: {}, test: { local: {}, remote: {} } }

But if I rename test.js to foobar.js, I get:

{ build: {}, foobar: {}, test: { local: {}, remote: {} } }

It would appear it can't require directories and files if they have the same.

aseemk commented 9 years ago

That's the default behavior by design since file extensions are stripped.

You can achieve what you want by passing duplicates: true. Then, you should get:

{
    build: {},
    'build.js': {},
    test: {
        local: {},
        'local.js': {},
        remote: {},
        'remote.js': {}
    },
    'test.js': {},
}
aseemk commented 9 years ago

Hope that helps; feel free to re-open if it doesn't!