nesh icon indicating copy to clipboard operation
nesh copied to clipboard

how to make local values available when embedding?

Open GeoffreyPlitt opened this issue 10 years ago • 5 comments

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

GeoffreyPlitt avatar Jun 15 '14 06:06 GeoffreyPlitt

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.

ccheever avatar Feb 24 '15 20:02 ccheever

globals is probably fine, can you explain further?

GeoffreyPlitt avatar Feb 24 '15 20:02 GeoffreyPlitt

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

ccheever avatar Mar 03 '15 15:03 ccheever

@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.

danielgtaylor avatar Mar 12 '15 17:03 danielgtaylor

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

GeoffreyPlitt avatar Mar 12 '15 18:03 GeoffreyPlitt