Skip to content

Conversation

@JerrySievert
Copy link
Contributor

this adds the option to include a bootstrap script to be run before the passed in script argument.

the use case for this would be to bootstrap the environment, such as allowing for shims etc to be loaded into the global context:

bootstrap.js:

var _require = global.require;
global.require = function (path) {
  print("Loading " + path);
  return _require(path);
};

var _print = global.print;
global.print = function (data) {
  _print("data => " + data);
};
$ dukluv -b ./bootstrap.js repl.js

opening as discussion since overwriting require does not seem to work, but overwriting anything else, or inserting it into global does seem to.

@JerrySievert
Copy link
Contributor Author

overriding Duktape.modResolve() does work in the bootstrap, which might be enough to make this work.

@JerrySievert
Copy link
Contributor Author

to see it in action:

https://github.com/JerrySievert/duk_modules

@creationix
Copy link
Owner

Sorry I missed this, are you still trying to get it in?

@JerrySievert
Copy link
Contributor Author

Wow. Had forgotten about this one. Will take a look tonight and review.

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

Successfully merging this pull request may close these issues.

2 participants