Re: [nodejs] How can I run a script while initializing an addon?

2012-06-25 Thread Hsu Ping Feng
I think the point is using package.json to define the module entry by an js file that wrap your addon. 2012/6/20 sahal > > Ok so instead of running "node.exe mymodule.node" I need to run "node.exe > -e require('mymodule.node').start(module); " > And in mymodule.cc write a function start() which

Re: [nodejs] How can I run a script while initializing an addon?

2012-06-19 Thread sahal
Ok so instead of running "node.exe mymodule.node" I need to run "node.exe -e require('mymodule.node').start(module); " And in mymodule.cc write a function start() which compiles and runs a v8::Function, passing it args[0] and work with it like with(arguments[0]) { console.log(require); } This

Re: [nodejs] How can I run a script while initializing an addon?

2012-06-19 Thread Nathan Rajlich
No, that's not what he's saying. Basically, instead of having the .node file be the "entry point" to your module, have a separate .js file that will act as the entry point, that also does other initialization like requiring your own native bindings. Then in your package.json file, the "main" field

Re: [nodejs] How can I run a script while initializing an addon?

2012-06-19 Thread sahal
On Tuesday, June 19, 2012 3:04:00 PM UTC+3, Ben Noordhuis wrote: > > On Tue, Jun 19, 2012 at 8:27 AM, sahal <> wrote: > > I'm wrapping a module into an addon. I want to run a standard nodejs > script > > when the module gets initialized, so that I only have to do "node > mymodule" > > from the

Re: [nodejs] How can I run a script while initializing an addon?

2012-06-19 Thread Ben Noordhuis
On Tue, Jun 19, 2012 at 8:27 AM, sahal wrote: > I'm wrapping a module into an addon. I want to run a standard nodejs script > when the module gets initialized, so that I only have to do "node mymodule" > from the command line. As far as I can see none of the usual module apis are > exposed. How ca

[nodejs] How can I run a script while initializing an addon?

2012-06-19 Thread sahal
I'm wrapping a module into an addon. I want to run a standard nodejs script when the module gets initialized, so that I only have to do "node mymodule" from the command line. As far as I can see none of the usual module apis are exposed. How can I do it then? Here's what I've tried: > #includ