nesh
nesh copied to clipboard
how to make local values available when embedding?
Hi,
I'm trying to embed a coffeescript REPL inside a coffeescript program. I've constructed a carefully-configured object that I'd like to pass into the REPL, which cannot easily be constructed by an eval'ed string.
Is there something like this available?
opts.locals= myobj: carefully_constructed_obj
Or how do I add something to nesh.defaults?
-G
Is there a reason they need to be locals and not globals? If they can be globals, there are a number of ways that aren't too hard to set them.
globals is probably fine, can you explain further?
Easiest way is probably to look at an the nesh-hello example plugin and then basically make a copy and just set context.whatever
to your object.
https://github.com/danielgtaylor/nesh-hello
@GeoffreyPlitt did you get this figured out? The example line that adds to the context is here:
https://github.com/danielgtaylor/nesh-hello/blob/master/hello.js#L8
There is no need to make a separate npm module for this. You can create an object with that postStart
method defined and pass that into the plugin loader, all within your project.
Cool, thanks. The project I was using this for isn't active anymore, but I'll keep this in mind for the future.
On Thu, Mar 12, 2015 at 10:16 AM, Daniel G. Taylor <[email protected]
wrote:
@GeoffreyPlitt https://github.com/GeoffreyPlitt did you get this figured out? The example line that adds to the context is here:
https://github.com/danielgtaylor/nesh-hello/blob/master/hello.js#L8
There is no need to make a separate npm module for this. You can create an object with that postStart method defined and pass that into the plugin loader, all within your project.
— Reply to this email directly or view it on GitHub https://github.com/danielgtaylor/nesh/issues/17#issuecomment-78533684.
http://www.geoffplitt.com http://facebook.com/geoffrey.plitt https://twitter.com/GeoffreyPlitt 773.339.0915