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

Improve args to support nested functions #29

Open
mateatslc opened this issue Dec 6, 2015 · 0 comments
Open

Improve args to support nested functions #29

mateatslc opened this issue Dec 6, 2015 · 0 comments

Comments

@mateatslc
Copy link

Functions that aren't defined as top-level properties of args are not making through to the loaded module source. So for example, this works fine:

// another-require.js
require('something');

// index.js
require = require('really-need');
require('./another-require', {
  args: {
    require: function (name) {
      console.log('no requires allowed');
    }
  }
});
// prints "no requires allowed"

... but this doesn't:

// stuff-with-lodash.js
console.log( _.yam );
_.filter();

// index.js
require = require('really-need');
require('./stuff-with-lodash', {
  args: {
    _: {
      'yam': 678,
      'filter': function () {
        console.log('look! a fake lodash filter!');
      }
    }
  }
});
// prints:
// 678
// _.filter is not a function

I already hacked together something that works using a dusty gist by @cowboy but I'm not in love with it.
Let me know if this is something you think worth looking into.

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

1 participant