isaacs
28e851c169
Warn about running npm in the repl
2012-06-05 12:35:49 -07:00
Nathan Rajlich
a608f65b24
repl: preserve the cursor when redisplaying the prompt on SIGCONT
...
Otherwise the cursor position was being reset to 0, even when there was
already part of a line, which was strange.
Part of #3295 .
2012-05-21 21:09:46 -03:00
Nathan Rajlich
f405daa922
repl: make tab completion read up the prototype of "global"
...
For example, there's a global "toString()" function, so the REPL's
tab completion should pick that up.
2012-04-25 20:34:34 -07:00
Nathan Rajlich
e16021340d
repl: use Object.getPrototypeOf on functions for tab complete()
2012-04-21 13:53:49 -07:00
Nathan Rajlich
327286dbcd
repl: update the repl
for the new readline
behavior
...
This fixes the failing REPL tests.
2012-04-17 11:53:50 -07:00
Nathan Rajlich
ca8dea83a9
repl: make the completer use newlines
...
Fixes the repl.complete() function when terminal is false, since it
is now explicitly looking for a '\n' char.
2012-04-06 16:13:40 -07:00
Nathan Rajlich
48bbdde66b
repl: don't write a newline on the readline 'end' event
...
In the case of the input stream *actually* having been closed, then we
can't write to a closed socket.
Fixes test/simple/test-repl.js
2012-03-28 08:42:40 -07:00
Nathan Rajlich
208b230744
repl: add a 'useColors' option to the repl
...
This should only be minimally used, since the `terminal` value will usually be
what you are expecting. This option is specifically for the case where `terminal`
is false, but you still want colors to be output (or vice-versa).
2012-03-27 18:00:59 -07:00
Nathan Rajlich
b187e96ec9
repl: add a 'writer' option to the repl
...
Previously this was a module-level setting, meaning that all REPL instances
had to share the same writer function. Turning it into one of the options
allows individual REPL instances to use their own writer function.
2012-03-27 17:39:14 -07:00
Nathan Rajlich
228ddddc1c
repl: ensure that 'repl.ignoreUndefined' is a boolean
2012-03-27 17:35:33 -07:00
Nathan Rajlich
e7065eaa93
repl: ensure that 'repl.useGlobal' is a boolean
2012-03-27 17:34:55 -07:00
Nathan Rajlich
f41901cdf6
repl: make ^D emit an 'end' event on the readline instance
...
Also emit 'exit' on the repl when 'end' is emitted on the readline.
Fixes `node debug test/fixtures/breakpoints.js` when ^D is pressed.
2012-03-27 13:54:49 -07:00
Nathan Rajlich
aad12d0b26
readline: migrate ansi/vt100 logic from tty to readline
...
The overall goal here is to make readline more interoperable with other node
Streams like say a net.Socket instance, in "terminal" mode.
See #2922 for all the details.
Closes #2922 .
2012-03-26 15:21:25 -07:00
Alex Kocharin
06a058d731
readline: row-agnostic multiline readline implementation
...
Fixes #2959 .
2012-03-20 15:37:06 -07:00
Alex Kocharin
415bff26fe
repl: fix space autocompletion bug
...
Tapping <SP> + <TAB> would exit the REPL.
2012-03-20 12:27:59 +01:00
Fedor Indutny
b6cb6ce0d3
debugger: remove 'repl' command from builtinLibs
...
* It was displaying useless warning
2012-03-19 22:21:28 +06:00
Nathan Rajlich
f214758dd1
repl: better SIGINT handling behavior
...
Before:
☮ ~ (master) ⚡ node
> asdf
(^C again to quit)
> sdcasd☮ ~ (master) ⚡
Now:
☮ ~/node (repl) ⚡ ./node
> asfs
> sda
>
(^C again to quit)
> scdsdc
> sdcsdc
>
(^C again to quit)
> sdc
>
(^C again to quit)
>
☮ ~/node (repl) ⚡
^ note that each new line above is a ctrl+c sequence
2012-03-13 19:58:52 +01:00
Nathan Rajlich
6b5a34cdf3
repl: remove redundant check of rli.rine.length
...
It get's set to '' 1 line above, so we know that that's always 0.
2012-03-13 19:58:52 +01:00
Nathan Rajlich
b7ddd30181
repl: make sure the REPL always flushes with a newline
2012-03-13 19:58:51 +01:00
Nathan Rajlich
659d449460
repl: make REPLServer emit an "exit" event
...
This can happen when "SIGINT" is processed by the readline interface,
or when the user types ".exit" into the REPL.
2012-03-13 19:58:50 +01:00
Nathan Rajlich
4f63f9f327
repl: make REPLServer inherit from EventEmitter
...
This is because it should emit an "exit" event when "SIGINT" is received
from the readline interface, or when ".exit" is typed by the user.
2012-03-13 19:58:50 +01:00
Nathan Rajlich
109b16d488
repl: use path.resolve() for the module.filename
...
Windows was seeing: "C:\\path\\to\\cwd/repl"
2012-03-13 19:58:49 +01:00
Colton Baker
fd61bfc731
readline: ^Z (SIGSTP) handling
...
Bugfix and update.
- Fixed bug where Node's REPL wouldn't continue when returning from ^Z
(SIGTSTP)
- Removed old readline callback
Readline API update with docs.
- ^Z (SIGTSTP) is now bypassed on Windows systems.
- SIGCONT is now bypassed on Windows systems.
- Docs updated to reflect above.
2012-02-22 16:07:23 -08:00
Brandon Benvie
b72277183f
repl: add automatic loading of built-in libs
2012-02-20 13:56:27 +01:00
isaacs
0cdf85e28d
Lint all the JavaScripts.
2012-02-18 15:34:57 -08:00
isaacs
31721da4b1
Merge remote-tracking branch 'ry/v0.6' into v0.6-merge
...
Conflicts:
AUTHORS
ChangeLog
Makefile
doc/about/index.html
doc/api/tls.markdown
doc/community/index.html
doc/index.html
doc/logos/index.html
doc/template.html
lib/http.js
lib/tls.js
src/node_version.h
src/platform_win32.cc
test/simple/test-tls-connect-given-socket.js
2012-02-18 09:46:58 -08:00
Fedor Indutny
ae5e23310e
repl: remove double calls where possible
...
Repl is doing double evaluation of code: wrapped in parens and without
them. That's needed to allow users typing multiline chunks of code by
handling syntax errors on repl side. However if function declaration is
wrapped in parens (`(function a() {})`) calling it will be impossible,
so we're evaluating functions twice. That works fine for declaration,
but if entered code chunk returns function - it should not be called
twice.
fix #2773
2012-02-18 00:30:52 +06:00
Nathan Rajlich
a118f21728
repl: make tab completion work on non-objects
2012-02-17 15:51:33 +01:00
Colton Baker
ce485791db
Readline proposal and bugfixes. Related: #2737 #2756
...
- Removed extra newline from .question(); Users can input a
newline if it they require it.
- Removed .close() due to it only emulating closing, causing a bug where
readline is left open to trigger events such as .on('line', ...').
- Removed ._attemptClose()
- .pause() now triggers event .on('pause', ...)
- .resume() now triggers event .on('resume', ...)
- CTRL-C (SIGINT) in readline will now default to .pause() if no SIGINT event
is present.
- CTRL-D (delete right) will also default to .pause() if there is nothing to
delete (signaling the end of the file).
- Added new event `SIGTSTP`
- Added new event `SIGCONT`
- Added `resume` to `write` to resume the stream if paused.
- Docs updated.
- Updated repl.js
2012-02-16 12:12:03 +06:00
Ben Noordhuis
c123ac05dc
Merge remote-tracking branch 'origin/v0.6'
...
Conflicts:
src/udp_wrap.cc
2012-01-02 12:29:39 +01:00
isaacs
8e57398b20
Fix #2034 repl message for .clear when useGlobal=true
2011-12-31 03:20:41 +01:00
Damon Oehlman
744ed46970
repl: fix repl.start not passing the ignoreUndefined
arg to the REPLServer constructor
2011-12-29 14:46:04 +01:00
Fedor Indutny
c07edd90f5
preserve cursor pos
...
* configurable via .prompt()'s preserveCursor argument (false by default)
2011-12-19 11:09:16 -08:00
seebees
3421f43351
.load, .save and local scope tab completion
...
Fixes #2063 .
REPLServer.prototype.resetContext:
Reset the line cache
REPLServer.prototype.memory (don't know if I like that name, called from finish)
pushes what cmd's have been executed against it into this.lines
pushes the "tab depth" for bufferedCommands, in this.lines.level
REPLServer.prototype.displayPrompt:
Uses "tab depth" from this.lines.level to adjust the prompt to visually
denote this depth e.g.
> asdf = function () {
… var inner = {
….. one:1
REPLServer.prototype.complete:
Now notices if there is a bufferedCommand and attempts determine locally
scoped variables by removing any functions from this.lines and evaling these
lines in a nested REPL e.g.
> asdf = function () {
… var inner = { one: 1};
… inn\t
will complete to 'inner' and inner.o\t will complete to 'inner.one'
If the nested REPL still has a bufferedCommand it will falls back to the
default.
ArrayStream is a helper class for the nested REPL to get commands pushed to it.
new REPLServer('', new ArrayStream());
Finally added two new REPL commands .save and .load, each takes 1 parameter,
a file and attempts to save or load the file to or from the REPL
respectively.
2011-11-12 11:34:55 -08:00
Fedor Indutny
9ad27f7853
ignore undefined messages in the debugger repl
...
fixes #1995
2011-11-02 15:55:36 -07:00
Nathan Rajlich
bdb9d09aef
Print out undefined
on the REPL when returned.
...
util.inspect() has a special case for "undefined", so it's nice to be able to
distinguish visually that undefined is the result of an expression.
2011-10-22 14:02:35 +09:00
isaacs
2d02e6a992
Add useGlobal flag for standard node repl
2011-10-21 13:02:49 -07:00
isaacs
caf70f5e94
Revert "Don't use a separate context for the repl."
...
This reverts commit b70fed48a7
.
2011-10-21 13:00:37 -07:00
Nathan Rajlich
95d530f2b4
repl: print out undefined
...
util.inspect() has a special case for "undefined", so it's nice to be able to
distinguish visually that undefined is the result of an expression.
2011-10-20 08:41:33 -07:00
isaacs
b70fed48a7
Don't use a separate context for the repl.
...
Fix #1484
Fix #1834
Fix #1482
Fix #771
It's been a while now, and we've seen how this separate context thing
works. It constantly confuses people, and no one actually uses '.clear'
anyway, so the benefit of that feature does not justify the constant
WTFery.
This makes repl.context actually be a getter that returns the global
object, and prints a deprecation warning. The '.clear' command is gone,
and will report that it's an invalid repl keyword. Tests updated to
allow the require, module, and exports globals, which are still
available in the repl just like they were before, by making them global.
2011-10-18 18:18:32 -07:00
Colton Baker
87286cc737
Fixed a lot of jslint errors.
...
Fixes #1831
2011-10-05 18:51:06 -07:00
Bert Belder
81425598db
Enable console colors on windows by default
2011-09-27 13:03:29 -07:00
Fedor Indutny
67706b8bb7
Export disableColors from repl, share with debugger
2011-09-27 11:58:02 +02:00
Fedor Indutny
2010071339
readline: custom streams support
2011-09-23 13:42:41 -07:00
Fedor Indutny
1e37efb08b
initial tests
...
* Don't buffer command, before it's execution (repl)
* `quit` command, custom streams for .start, stubbed out test, disable
history repeation for non-tty (debugger)
2011-09-23 09:38:24 -07:00
Fedor Indutny
41a41825f6
micro-refactor, use rli.output.write instead of rli.write ('line' event was emitted for those writes)
2011-09-20 08:35:15 -07:00
Ryan Dahl
a1bafc5566
Merge remote branch 'origin/v0.4'
...
Conflicts:
deps/http_parser/http_parser.c
deps/http_parser/test.c
lib/repl.js
2011-09-15 11:48:37 -07:00
isaacs
e06ce7562c
Fix #1707 hasOwnProperty usage
...
If hasOwnProperty is overridden, then calling `obj.hasOwnProperty(prop)`
can fail. Any time a dictionary of user-generated items is built, we
cannot rely on hasOwnProperty being safe, so must call it from the
Object.prototype explicitly.
2011-09-15 10:54:08 -07:00
isaacs
98990b9779
Fix #1707 hasOwnProperty usage
2011-09-15 09:46:30 -07:00
Fedor Indutny
57388d8b2e
[repl] add error handling for async scope fetching
2011-09-13 20:40:21 -07:00
Fedor Indutny
df480e0357
fix syntax error handling for 'throw ...', fix return value assertion
2011-09-11 02:19:42 -07:00
Fedor Indutny
e13ed4a8d0
[repl, readline] refactor async completion and execution
2011-09-09 02:06:07 +07:00
Fedor Indutny
0d4dc3a8b5
[repl] let self.eval be configurable on REPLServer initialization
2011-09-09 02:06:06 +07:00
Fedor Indutny
eab65e214e
[repl] Async global completion
2011-09-09 02:06:06 +07:00
Fedor Indutny
71a9aefa0f
[readline, repl] Fix completion grouping, fix parens eval results
...
handling
2011-09-09 02:06:06 +07:00
Fedor Indutny
42b8b77d9f
[repl, readline] async interface
...
Add async completion and execution interface for repl and readline
2011-09-09 02:06:06 +07:00
Nathan Rajlich
cf24f561a3
repl: don't eval twice when an Error is thrown
2011-09-01 17:15:07 +02:00
Nathan Rajlich
8ec31a3362
Use Object.getPrototypeOf() on the object in the REPL tab-completion.
...
Some people use __proto__ to augment an Object's prototype after it's been created.
This patch helps make the "new" prototype properties visible if necessary.
This is also more consistent with the while logic below.
2011-08-23 15:35:36 -07:00
Robert Mustacchi
de0b8d601c
jslint cleanup: path.js, readline.js, repl.js, tls.js, tty_win32.js, url.js
2011-07-29 11:58:02 -07:00
isaacs
c050d0fa19
Finish removing require.paths
...
Fix require() completion bug in repl, and correct man output
2011-07-24 18:04:45 -07:00
isaacs
205b9beb6b
Merge branch 'v0.4'
...
Conflicts:
lib/tls.js
lib/url.js
src/node_version.h
test/simple/test-buffer.js
test/simple/test-url.js
2011-05-07 20:38:32 -07:00
isaacs
bbffd9e502
Close #983 Better JSON.parse error detection
...
Previous pattern would only catch ILLEGAL, not { or other
known-but-unexpected JSON tokens.
2011-04-26 09:48:28 -07:00
Tim Baumann
6c7c4aeab6
Don't overwrite an user-specified repl.writer
2011-04-21 12:26:27 -07:00
Wade Simmons
d00739ce56
make it possible to do repl.start('', stream)
2011-04-21 12:20:50 -07:00
isaacs
0b3ecc05a6
Close #955 Change ^C handling in REPL
...
Press with text on the line: Cancels
Press on a bare line: Print a message
Press again on a bare line: Exit
2011-04-21 12:17:21 -07:00
Ben Weaver
d63a551f86
Update how REPLServer uses contexts
...
* Always use `this.context` or `self.context`.
* Move `resetContext` to `REPLServer.createContext`.
* Add `REPLServer.resetContext`, memoize `context` here.
* Memoize `exports.repl` in `start`.
Closes GH-851.
2011-04-11 16:52:23 -07:00
Ryan Dahl
55048cdf79
Update copyright headers
2011-03-14 17:37:05 -07:00
isaacs
a48f73d0d3
Closes GH-232 Make the repl's global the right thing
2011-02-27 17:13:52 -08:00
isaacs
2cfe7b847d
Closes GH-184 Clear require cache on repl .clear
2011-02-27 17:07:08 -08:00
isaacs
f07041e6cd
Make the repl respect node_modules folders.
...
This is important so that in the future, this will work:
$ cd ~/dev/js/some-project
$ npm install redis
$ node
> require.resolve('redis')
'/Users/isaacs/dev/js/some-project/node_modules/redis/index.js'
2011-02-14 13:43:22 -08:00
Ryan Dahl
192d2e0803
REPL: disable colors in windows for now
2011-01-28 12:58:19 -08:00
Ryan Dahl
9e976abad9
lint
2011-01-24 10:55:30 -08:00
Ryan Dahl
ba80d4d8a9
Transfer data gathering responsibility to readline
...
Fixes non-raw REPL/Debugger on Posix.
2011-01-19 11:46:16 -08:00
Bert Belder
4475b76535
Readline: use symbolic key names instead of ascii control codes
2011-01-18 23:22:38 -08:00
Ryan Dahl
5a05992155
Lint
2011-01-06 16:06:27 -08:00
Bert Belder
1ac133ea6f
Replace string magic + path.join by path.resolve
...
Because path.resolve is more elegant and windows-safe.
2011-01-06 15:39:51 -08:00
Ryan Dahl
b6dafc1a47
Allow for two streams in REPL
...
Towards windows compatibility.
2011-01-06 13:42:32 -08:00
Ryan Dahl
feb77eab65
Fix REPL for named functions
...
add some tests.
2011-01-02 18:27:14 -08:00
Ryan Dahl
c82fe30ca1
repl.js style
2011-01-01 21:41:07 -08:00
Ryan Dahl
00974df3e5
Allow for evaling statements in REPL too
2011-01-01 21:05:23 -08:00
Ryan Dahl
b45698e676
Improve how REPL commands are evaled
...
Before:
> {a: 1}
1
> (function() {
... // foo
... return 1;
... })();
...
Now:
> {a: 1}
{ a : 1 }
> (function() {
... // foo
... return 1;
... })();
1
>
2011-01-01 17:54:48 -08:00
Brian White
6d75c06e64
Add os module to repl's built-in lib list
2010-12-16 17:37:00 -08:00
Brian White
e41e078159
Make sure REPL doesn't get borked when invalid REPL keywords are entered
2010-12-03 09:57:36 -08:00
Ryan Dahl
e232f6e735
more lint
2010-12-01 20:28:28 -08:00
Marco Rogers
118b88e44f
update repl to distinguish JSON.parse SyntaxErrors from the rest
2010-11-20 20:36:14 -08:00
Brian White
5908bdab9a
Make sure raw mode is disabled when exiting a terminal-based REPL.
2010-11-17 18:45:34 -08:00
Ryan Dahl
8e09b1e2e1
Simplify REPL displayPrompt
...
Now that we insert \r into the stream and aren't switching back and forth
between termios modes, not need to worry about when to display the prompt.
2010-11-12 14:39:42 -08:00
isaacs
bfc6b51d95
The cwdRequire hack is no longer necessary with the require.resolve refactor.
2010-10-20 15:22:02 -07:00
isaacs
226eff5104
Add require.resolve.
...
Also, hack the repl so that it works as expected there, too.
2010-10-20 12:12:07 -07:00
Sami Samhuri
56df0cbf93
new api for defining repl commands
2010-10-18 13:46:54 -07:00
Micheil Smith
e38eb0c5a4
Soft migration of sys -> util, Removal of deprecated utils module.
2010-10-11 15:21:36 -07:00
Ryan Dahl
783f5019b0
Add flag to disable colors in REPL
2010-10-09 12:46:06 -07:00
Sean Coates
ae87007478
add $ to variable name character matching patterns in repl completer
2010-10-09 10:04:13 -07:00
Joshaven Potter
3d4e4d8909
syntax fixes to pass jslint
2010-10-06 20:40:57 -07:00
Ryan Dahl
5829716649
Fix REPL crash on tabbing 'this.'
...
Thanks to Tim Becker for pointing this out.
2010-10-01 11:31:22 -07:00
Ryan Dahl
d2de8ba400
^c to get out of '...' in REPL
2010-09-16 21:07:22 -07:00
Ryan Dahl
42eb5a6898
Simplify REPL
2010-09-16 20:50:56 -07:00
Trent Mick
1d961a6630
add ANSI coloring option to sys.inspect and, by default, to the repl
2010-09-08 09:47:13 -07:00
Trent Mick
293809b8b6
drop obsolete TODO comment
2010-08-18 23:02:54 -07:00
Trent Mick
5c1ffa165f
repl completion: completion for arguments to "require"
2010-08-18 22:59:49 -07:00
Trent Mick
2134982ea4
repl completion: comment/TODO cleanup, no functional change
2010-08-18 22:59:35 -07:00
Trent Mick
1c9a85b9a6
First pass at tab-completion in the REPL
2010-08-11 13:42:45 -07:00
Blake Mizerany
8c8534046c
fix whitespace errors
2010-06-29 23:59:24 -07:00
Ruben Rodriguez
242161bef2
Added new API to Script, and implemented it in the REPL
2010-06-28 15:16:26 -07:00
isaacs
e65e6039a8
Fix #169 . Expose require members in the repl.
...
This fixes #169 by putting the require members onto the cwdRequire function
which is exposed to the repl scope.
2010-06-11 14:04:58 -07:00
Ryan Dahl
adc06dd705
Add NODE_NO_READLINE check for REPL
...
Setting this environmental variable to a non-zero integer will start all
REPL interfaces without readline. For use with rlwrap.
2010-06-08 15:44:43 -07:00
Ryan Dahl
a6942b345d
Fix test-repl
2010-06-07 17:39:52 -07:00
Matt Ranney
09af242c89
Support more readline navigation keys.
2010-06-07 16:51:07 -07:00
Ryan Dahl
41f213be18
Add binding to termios, implement readline for repl
2010-06-07 15:24:21 -07:00
isaacs
a26f7d753d
Make require() from the repl be relative to cwd
2010-05-29 12:35:30 -07:00
isaacs
82813f2f8c
Execute repl code in new context
2010-05-29 12:33:55 -07:00
Ryan Dahl
e97a481785
Destroy REPL pipes instead of shutting down.
2010-05-24 17:14:13 -07:00
Matt Ranney
39464b498f
Add docs for new REPL options and fill out description of commands.
2010-04-15 18:03:56 -07:00
Matt Ranney
b7441040f8
REPL can be run from multiple different streams.
...
e.g. from UNIX sockets with socat.
2010-04-12 00:31:51 -07:00
isaacs
57fbb627ca
trailing whitespace fixes
2010-04-11 14:48:23 -07:00
isaacs
de9778b5bd
Add line breaks to the code when the user types a line break
2010-04-08 08:12:30 -07:00
Ryan Dahl
fdf46a65c9
Use streams for stdout and stdin
2010-03-15 15:11:40 -07:00
elliottcable
52f088b966
Providing the option for a repl-printer other than sys.p
2010-01-05 00:14:03 -08:00
visionmedia
a650138ebf
Moved help msg to node-repl
2010-01-04 22:06:18 -08:00
Ryan Dahl
7a2e784ad7
Module refactor - almost CommonJS compatible now
...
API change summary:
* require("/sys.js") becomes require("sys")
* require("circle.js") becomes require("./circle")
* process.path.join() becomes require("path").join()
2009-10-31 19:10:30 +01:00
Ryan Dahl
ad0a4cefb8
Namespace EVERYTHING under process; introduce GLOBAL
...
http://groups.google.com/group/nodejs/browse_thread/thread/1034fd2ad2cd93e8
2009-10-29 23:36:41 +01:00
Ryan Dahl
2b8ab7e24f
utils.js links to sys.js instead of other way around
2009-10-13 19:55:28 +02:00
Ryan Dahl
27738d8e60
Clean up some things in the repl, add docs.
2009-09-28 18:48:19 +02:00
Ryan Dahl
c27d9f986a
include utils in the repl.
2009-09-28 18:48:18 +02:00
Ryan Dahl
7abad8b7b3
API: Move node.puts(), node.exec() and others to /utils.js
2009-09-28 12:06:30 +02:00
Ryan Dahl
4f69871c17
Add node.inspect() and deprecate p().
2009-09-27 12:33:44 +02:00
RayMorgan
028e24c9f5
When printing, check to see if value is undefined. If so, print nothing.
2009-09-24 22:16:07 -07:00
RayMorgan
7674bd5004
Added _ that is te result of the previous command.
2009-09-24 19:53:11 -07:00
RayMorgan
6915188a46
Enhanced the repl library.
...
Now supports:
- command options: .help, .break, .clear, .exit
- local vars and global functions
- ability to print 0, false and ""
- when value is a function, prints [Function]
- when object is circular, prints [Circular Object] instead of throwing an error
2009-09-24 18:56:37 -07:00
Ryan Dahl
ffded5ac86
Extract the good parts of node-repl into standalone library.
...
Now you can require("/repl.js") in your server to be able to examine it
while it's running.
2009-09-24 00:56:24 +02:00