Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edge case bug in the local path resolver #81

Open
jasisk opened this issue Nov 18, 2016 · 1 comment
Open

edge case bug in the local path resolver #81

jasisk opened this issue Nov 18, 2016 · 1 comment

Comments

@jasisk
Copy link
Contributor

jasisk commented Nov 18, 2016

Plonk.

tryRequire just calls require.resolve which will, for local files, start relative to the file that contains it.

Therefore, if you try to require a file with a relative path that could resolve to a similarly named file from the util folder in meddleware, 💥.

Proof:

$ echo "console.log('i am required');" > rq.js

$ cat - > index.js <<EOF
const meddleware = require('meddleware');
const express = require('express');

const app = express();

const config = {
  example: {
    module: './rq.js'
  }
};

app.use(meddleware(config));
EOF

$ node index.js
/cat/city/secret/path/node_modules/meddleware/index.js:100
            throw new Error('Unable to locate middleware in ' + config.name);
            ^

Error: Unable to locate middleware in ./rq.js
shaunwarman pushed a commit to shaunwarman/meddleware that referenced this issue Nov 18, 2016
@shaunwarman
Copy link
Member

@jasisk I took a shot in #82 but I'm not sure it's the right approach. Will let you decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants