Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

node JS parameters #494

Closed
zachaller opened this issue May 2, 2013 · 14 comments
Closed

node JS parameters #494

zachaller opened this issue May 2, 2013 · 14 comments
Labels
good first issue Should be a fairly simple issue; feel free to ask for help! nodejs

Comments

@zachaller
Copy link

is there a way to pass params to a node js connections such as harmony for your project we need harmony support so we normally start node with

node --harmony app.js

@ibdknox
Copy link
Member

ibdknox commented May 2, 2013

not right now, but you could be tricky and alias node to node --harmony and as long as you run LT from a shell with that set, it should pick it up.

@skeet70
Copy link

skeet70 commented Jun 27, 2013

+1 on this feature. Hoping to develop with app.js using LightTable, would be great if it was possible. I couldn't get your suggested workaround to work.

@fbender
Copy link

fbender commented Sep 25, 2013

I'd like to see that, too. For nodeJS, there could just be a special behaviour that automatically sets the harmony flag!

(Also, I think there is enough room for a simple checkbox in the connector panel, however that changes the consistent UI a bit …)

@eafzali
Copy link

eafzali commented Jan 11, 2014

@ibdknox I've tested aliasing node and running light from shell but it doesn't worked for me i'm using the latest version downloaded from lighttable.com on OS X Lion.

@cldwalker
Copy link
Member

We don't have the bandwidth to take this on but happy to talk someone through a pull request. Basically, you'll want to provide a means to change these args to node. If people want the same args by default, then a behavior is the way to go. If people want to specify this on every connection, then a dialog like the one for Clojure nREPL is the way to go.

@cldwalker cldwalker added the good first issue Should be a fairly simple issue; feel free to ask for help! label Oct 17, 2014
@frankcash
Copy link

If this issue is still open I'd be happy to attempt to solve it

@gavocanov
Copy link

+1, it's a must have IMHO
BTW, the alias workaround does not work here on OSX 10.10.3

@kenny-evitt
Copy link
Contributor

I think I've got this working.

I've only been running it against a local build of the latest atom-shell branch (on a Mac).

To use, add an entry like this to your user.behaviors file:

[:app :lt.plugins.js.node/node-js.start-options "--harmony"]

I used the hello-world example from the Koa example apps:

and connected Node.js to the app.js file for that example. I can then access the example at http://localhost:3000 tho I do see the following logged to the console:

app.js[stderr]:
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1156:14)
    at listen (net.js:1182:10)
    at Server.listen (net.js:1267:5)
    at Application.app.listen (/Users/kenny/@code/examples/node_modules/koa/lib/application.js:69:24)
    at /Users/kenny/@code/examples/hello-world/app.js:9:25
    at Object.exports.runInContext (vm.js:64:17)
    at sbRequire (/Users/kenny/@code/LightTable/builds/lighttable-0.8.0-mac/LightTable.app/Contents/Resources/app/plugins/Javascript/node/ltnodeclient.js:99:10)
    at init (/Users/kenny/@code/LightTable/builds/lighttable-0.8.0-mac/LightTable.app/Contents/Resources/app/plugins/Javascript/node/ltnodeclient.js:121:3)
    at Socket.<anonymous> (/Users/kenny/@code/LightTable/builds/lighttable-0.8.0-mac/LightTable.app/Contents/Resources/app/plugins/Javascript/node/ltnodeclient.js:20:5)

The example continues to work even after the above error is logged.

@kenny-evitt
Copy link
Contributor

@zachaller @skeet70 @fbender @eafzali @gavocanov Anyone interested or willing to test my initial attempt? You should be able to clone my fork into the plugin directory and then refresh the plugin list in LT.

@frankcash If you're still available and willing to help, I'd appreciate a review of my changes.

@kenny-evitt kenny-evitt self-assigned this Aug 15, 2015
@gavocanov
Copy link

@kenny-evitt I built the latest atom-shell branch, cloned your fork in the plugins directory and it works like a charm, all "harmony" features seems working (let, const, arrow functions etc.).

Thanks a lot!

@cldwalker
Copy link
Member

@kenny-evitt I've verified this works with a few harmony features:

"foo".contains("f")
"f".startsWith("f")
var a = [
  "Hydrogen",
  "Helium",
  "Lithium",
  "Beryl­lium"
];
a.map( s => s.length );

Nice work!
Code feedback:

  • Most of LT's behaviors don't log to console and if they do it's because the user isn't sure what/when something has been set. This behavior seems straightforward (if behavior present -> enabled) and so we probably don't need it. Your call
  • Given the behavior is already in a lt.plugins.js.node namespace, adding a node-js subnamespace seems redundant. Perhaps node-start-options?
  • Could you remove client-command in your PR? It's not being used and if it were it would've been in the :args you changed?

@cldwalker
Copy link
Member

@kenny-evitt Your branch is close to knocking this out. Want to open a PR for it and address the minor feedback?

@kenny-evitt
Copy link
Contributor

@cldwalker Thanks for the eyes. I created a PR for my changes and I just pushed a rebase of my changes and your suggestions.

The console logging was just a quick aid for debugging.

I don't remember why I named the behavior the original name. I changed it to your suggestion.

I removed client-command.

@kenny-evitt
Copy link
Contributor

This is in the latest version of the JavaScript plugin. You should be able to update to that version from within LT.

@kenny-evitt kenny-evitt removed their assignment Feb 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Should be a fairly simple issue; feel free to ask for help! nodejs
Projects
None yet
Development

No branches or pull requests

9 participants