dukluv icon indicating copy to clipboard operation
dukluv copied to clipboard

ability to specify a bootstrap script [DISCUSSION]

Open JerrySievert opened this issue 11 years ago • 4 comments

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 avatar Jan 03 '15 22:01 JerrySievert

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

JerrySievert avatar Jan 03 '15 23:01 JerrySievert

to see it in action:

https://github.com/JerrySievert/duk_modules

JerrySievert avatar Jan 04 '15 01:01 JerrySievert

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

creationix avatar Apr 13 '16 19:04 creationix

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

JerrySievert avatar Apr 13 '16 20:04 JerrySievert