0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
Commit Graph

444 Commits

Author SHA1 Message Date
Joyee Cheung
19e3e02a2d
src: move SIGINT watchdog utils to the contextify binding
These are used when evaluating scripts so it makes more sense
to put them in the contextify binding whose other methods are
going to be used together.

PR-URL: https://github.com/nodejs/node/pull/27290
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-22 18:43:40 +08:00
Michaël Zasso
908292cf1f lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-04-12 05:38:45 +02:00
Ruben Bridgewater
d11c4beb4b
module: remove dead code
This removes a lot of code that has no functionality anymore. All
Node.js internal code calls `_resolveLookupPaths` with two arguments.

The code that validates `index.js` is not required at all as we check
for these files anyway, so it's just redundant code that should be
removed.

PR-URL: https://github.com/nodejs/node/pull/26983
Refs: https://github.com/nodejs/node/pull/25362
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-04-08 18:56:17 +02:00
Michaël Zasso
0817840f77 lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it.

PR-URL: https://github.com/nodejs/node/pull/27027
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-03 21:36:08 +08:00
Ruben Bridgewater
f86f5736da
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679

PR-URL: https://github.com/nodejs/node/pull/26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-30 13:16:39 +01:00
dnlup
415a825dc0 repl: remove usage of require('util') in repl.js
Use `require('internal/util/inspect').inspect` and
`require('internal/util/debuglog').debuglog` instead of
`require('util').inspect` and `require('util').debuglog`.

Refs: https://github.com/nodejs/node/issues/26546

PR-URL: https://github.com/nodejs/node/pull/26820
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-03-29 22:20:05 +08:00
Ruben Bridgewater
b08a867d60
benchmark,doc,lib: capitalize more comments
PR-URL: https://github.com/nodejs/node/pull/26849
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-03-27 17:20:06 +01:00
Ruben Bridgewater
97737fd5fb
repl: fix terminal default setting
This makes sure that the described default behavior for the
`terminal` option is actually always used and not only when running
the REPL as standalone program.

The options code is now logically combined instead of being spread
out in the big REPL constructor.

PR-URL: https://github.com/nodejs/node/pull/26518
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-25 16:28:07 +01:00
Vladislav Kaminsky
82b3ee776b
repl: check colors with .getColorDepth()
PR-URL: https://github.com/nodejs/node/pull/26261
Fixes: https://github.com/nodejs/node/issues/26187
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-03-21 23:34:14 +01:00
gengjiawen
ccdaa434b8 repl: remove redundant initialization
PR-URL: https://github.com/nodejs/node/pull/26562
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-03-15 10:23:12 +01:00
gengjiawen
024842f8f4
repl: eliminate var in function _memory
PR-URL: https://github.com/nodejs/node/pull/26496
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-13 16:32:04 +01:00
gengjiawen
2c1a8c85d2
repl: simplify regex expression
PR-URL: https://github.com/nodejs/node/pull/26496
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-13 16:32:03 +01:00
gengjiawen
a26e9a8a57
repl: remove redundant escape
PR-URL: https://github.com/nodejs/node/pull/26496
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-13 16:32:02 +01:00
Ruben Bridgewater
82f8821401 repl: add replDefaults to customize the writer
So far it was not possible to modify the inspection defaults used by
the REPL from the running instance itself. This introduces a new
property on `util.inspect` which is only used inside the REPL and which
allows to modify the used inspection defaults at any point of time.

PR-URL: https://github.com/nodejs/node/pull/26375
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-08 04:44:56 +01:00
Anna Henningsen
a0778a97e1
repl: use object writer for thrown errors
This makes us use the defaults that were set for the REPL, i.e.
aligns with the printing of expression completion values, and in
particular enables color support.

PR-URL: https://github.com/nodejs/node/pull/26361
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-04 00:12:07 +01:00
cjihrig
4afd503465
doc,test,repl: fix deprecation code
PR-URL: https://github.com/nodejs/node/pull/26368
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-03-01 13:11:02 -05:00
Ruben Bridgewater
584305841d
repl: deprecate REPLServer.rli
This is only a reference to the instance and should not be used.

PR-URL: https://github.com/nodejs/node/pull/26260
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-01 00:13:34 +01:00
Ruben Bridgewater
df43754fe1 repl: hide editor mode if not used in a terminal
The editor mode is only useable when used as terminal. Hide it from
the user in case the repl terminal option is not set.

PR-URL: https://github.com/nodejs/node/pull/26240
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-02-28 05:21:07 +01:00
Ruben Bridgewater
197690972c repl: add new line on ctrl+d
Currently the repl ends on the same line which procudes a weird
output. To prevent that, just add a new line in case of ctrl+d.

PR-URL: https://github.com/nodejs/node/pull/26240
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-02-28 05:21:02 +01:00
Ruben Bridgewater
ff64c6722f repl: add more information
This adds information about how to close the repl.

PR-URL: https://github.com/nodejs/node/pull/26240
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-02-28 05:20:51 +01:00
Lance Ball
0aa74443d8
repl: add repl.setupHistory for programmatic repl
Adds a `repl.setupHistory()` instance method so that
programmatic REPLs can also write history to a file.

This change also refactors all of the history file
management to `lib/internal/repl/history.js`, cleaning
up and simplifying `lib/internal/repl.js`.

PR-URL: https://github.com/nodejs/node/pull/25895
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2019-02-11 14:30:26 -05:00
Michaël Zasso
582c12260e
deps: update acorn to 6.0.7
acorn and acorn-walk are now published as two different packages. Put
them both in subdirectories of `deps/acorn`.
Adapt the REPL's recoverable error detection to use the new API for
extending acorn parsers.

PR-URL: https://github.com/nodejs/node/pull/25844
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-08 15:34:10 +01:00
Ruben Bridgewater
8c12a78d20 repl: remove obsolete buffer clearing
It is checked if an command buffer exists or not. This code branch
can only be reached if none exist, so there's no need to clear that
buffer again.

PR-URL: https://github.com/nodejs/node/pull/25731
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-06 07:37:48 +01:00
Ruben Bridgewater
f9fe037088 repl: fix eval return value
In case no error has occurred during the evaluation of some code,
`undefined` has been returned in some cases as error argument instead
of `null`. This is fixed by this patch.

PR-URL: https://github.com/nodejs/node/pull/25731
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-06 07:30:39 +01:00
Ruben Bridgewater
e3055dc525 repl: simplify and improve completion
The completion lists used a hand crafted list of global entries that
was redundant due to also using the actual global properties for tab
completion. Those entries ended up in an separated completion group
which did not seem useful.

PR-URL: https://github.com/nodejs/node/pull/25731
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-06 07:30:28 +01:00
Ruben Bridgewater
edde065191
repl: indicate if errors are thrown or not
Currently an error is printed identical, no matter if it is just
inspected or if the error is thrown inside of the REPL. This makes
sure we are able to distinguish these cases.

PR-URL: https://github.com/nodejs/node/pull/25253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-02 14:58:47 +01:00
Ruben Bridgewater
4b7a530f2b
lib: switch to object spread where possible
Use the object spread notation instead of using Object.assign.
It is not only easier to read it is also faster as of V8 6.8.

PR-URL: https://github.com/nodejs/node/pull/25104
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-12-20 13:14:46 +01:00
Ruben Bridgewater
50dd555910
doc,lib,test: capitalize comment sentences
This activates the eslint capitalize comment rule for comments
above 50 characters.

PR-URL: https://github.com/nodejs/node/pull/24996
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-17 17:14:35 +01:00
Ruben Bridgewater
b1ada6c9de Revert "lib: repl multiline history support"
This reverts commit dd7a3d246d.

PR-URL: https://github.com/nodejs/node/pull/24804
Refs: https://github.com/nodejs/node/issues/24231
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-12-05 23:36:10 -08:00
Ruben Bridgewater
fd2467aeaa Revert "repl: handle buffered string logic on finish"
This reverts commit eb42c1eb4f.

PR-URL: https://github.com/nodejs/node/pull/24804
Refs: https://github.com/nodejs/node/issues/24231
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-12-05 23:36:06 -08:00
Ruben Bridgewater
59257543c3
lib: use ES6 class inheritance style
PR-URL: https://github.com/nodejs/node/pull/24755
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-12-05 16:55:00 +01:00
Ruben Bridgewater
dcc82b37b6
lib: remove inherits() usage
This switches all `util.inherits()` calls to use
`Object.setPrototypeOf()` instead. In fact, `util.inherits()` is
mainly a small wrapper around exactly this function while adding
the `_super` property on the object as well.

Refs: #24395

PR-URL: https://github.com/nodejs/node/pull/24755
Refs: https://github.com/nodejs/node/issues/24395
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-12-05 16:53:58 +01:00
Anto Aravinth
eb42c1eb4f repl: handle buffered string logic on finish
Looks like `clearBufferedCommand` will be called on almost all flows.
Hence history was broken.

PR-URL: https://github.com/nodejs/node/pull/24389
Fixes: https://github.com/nodejs/node/issues/24385
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-11-19 10:47:41 -08:00
Gus Caplan
7082c61e27 Revert "util: change util.inspect depth default"
This reverts commit ac7450a09a.

This fully reverts the changes to util.inspect depth.

It has caused breakage in logging to existing apps, and even
something as simple as `console.log(require)` will cause >1m freezes.

I've heard nothing but negative feedback (seriously not a single
person has expressed anything positive about this change) and
personally i find this change extremely annoying.

PR-URL: https://github.com/nodejs/node/pull/24326
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
2018-11-14 19:44:39 -08:00
Joyee Cheung
f895b5a58e src: cache the result of GetOptions() in JS land
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: https://github.com/nodejs/node/pull/24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-07 20:40:38 -08:00
cjihrig
a7ba5faaf5
repl: remove unused catch bindings
PR-URL: https://github.com/nodejs/node/pull/24079
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
2018-11-06 10:59:13 -05:00
MaleDong
9a20a12830 lib:fix grammar error and make it clearer for comments
1) Should be passive voice instead of `can overridden`.
2) Change the order of the two sentences to make it more clear about
'What can be overridden' instead of 'Can be overridden'.

PR-URL: https://github.com/nodejs/node/pull/23799
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-05 21:58:20 -08:00
Weijia Wang
c1e670338b repl: use promise#finally
PR-URL: https://github.com/nodejs/node/pull/23971
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-11-03 19:40:18 -07:00
Anto Aravinth
dd7a3d246d lib: repl multiline history support
PR-URL: https://github.com/nodejs/node/pull/22153
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-11-02 13:56:33 -07:00
Jose Bucio
f1b95467dc repl: migrate from process.binding('config') to getOptions()
PR-URL: https://github.com/nodejs/node/pull/23684
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-22 14:57:20 -07:00
Khalid Adil
f0c5c962ce repl: remove unused variable e from try catch
PR-URL: https://github.com/nodejs/node/pull/23449
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-13 09:08:12 -07:00
Gus Caplan
e7f710c1d4 bootstrapper: move internalBinding to NativeModule
internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: https://github.com/nodejs/node/pull/23025
Refs: https://github.com/nodejs/node/commit/2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-04 11:55:34 +02:00
Ruben Bridgewater
ac7450a09a
util: change util.inspect depth default
The current default is not ideal in most use cases. Therefore it is
changed to inspect objects to a maximum depth of 20 in case
util.inspect is called with it's defaults. The default is kept at 2
when using console.log() and similar in the repl.

PR-URL: https://github.com/nodejs/node/pull/17907
Refs: https://github.com/nodejs/node/issues/12693

PR-URL: https://github.com/nodejs/node/pull/22846
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2018-10-02 22:43:09 +02:00
Rich Trott
83d0404971 repl: do not swallow errors in nested REPLs
For tab completion, a REPLServer instance will sometimes create another
REPLServer instance. If a callback is sent to the `.complete()` function
and that callback throws an error, it will be swallowed by the nested
REPLs domain. Re-throw the error so that processes don't silently exit
without any indication of an error (including a status code).

Fixes: https://github.com/nodejs/node/issues/21586

PR-URL: https://github.com/nodejs/node/pull/23004
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-10-02 13:07:18 -07:00
cjihrig
2bf4697ff4
repl: remove duplicate util binding
PR-URL: https://github.com/nodejs/node/pull/22675
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-09-05 21:53:43 -04:00
cjihrig
7e4b0a4850
util: make util binding internal
Refs: https://github.com/nodejs/node/issues/22160
PR-URL: https://github.com/nodejs/node/pull/22675
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-09-05 21:53:11 -04:00
Ruben Bridgewater
2eef077834
repl: refactor ERR_SCRIPT_EXECUTION_INTERRUPTED stack handling
The stack was removed later on instead of never being attached in
the first place.

PR-URL: https://github.com/nodejs/node/pull/22436
Refs: https://github.com/nodejs/node/issues/20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-27 14:08:44 +02:00
Ruben Bridgewater
ccb303e037
repl: improve error output
1) Currently extra properties on an error will be ignored, if thrown.
   This information will from now on be visible.
2) In case someone threw a non error object it would have resulted in
   `[object Object]`. Instead, the full object will now be visible.
3) Some cases were not detected properly as error before and "Thrown: "
   was visible before. That is now fixed.

PR-URL: https://github.com/nodejs/node/pull/22436
Refs: https://github.com/nodejs/node/issues/20253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-27 14:08:43 +02:00
Ruben Bridgewater
68b07ded9c
repl: tab auto complete big arrays
Due to a new API it's possible to skip the indices. That allows to
use auto completion with big (typed) arrays.

PR-URL: https://github.com/nodejs/node/pull/22408
Fixes: https://github.com/nodejs/node/issues/21446
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-08-23 00:10:52 +02:00
MaleDong
801814686d lib: remove unused filterInternalStackFrames param
Actually we don't refer the `error` directly in
`filterInternalStackFrames`, so just remove it anyway.

PR-URL: https://github.com/nodejs/node/pull/22267
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-14 11:52:46 -04:00
Sam Ruby
a2ec80851c repl: support mult-line string-keyed objects
isRecoverableError is completely reimplemented using acorn and an
acorn plugin that examines the state of the parser at the time of the
error to determine if the code could be completed on a subsequent line.

PR-URL: https://github.com/nodejs/node/pull/21805
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-03 20:20:00 -07:00
Sam Ruby
4d42083d1a
repl: make own properties shadow prototype properties
Previously, the code displayed properties backwards (e.g., showing
prototype properties before own properties).  It also did uniqueness
checks during this processing, so these checks were done backwards.

After this change, the properties continue to be displayed backwards,
but the uniqueness checks are done in the proper order.

See also: https://github.com/nodejs/node/issues/21586 which was
discovered during the testing of this fix.

Fixes: https://github.com/nodejs/node/issues/15199
PR-URL: https://github.com/nodejs/node/pull/21588
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-07-13 18:57:16 +02:00
Weijia Wang
4f15122847 repl: fix tab completion for object properties with special char
The old RegExp will pass property names like `"hello world!"`
when filtering the results of tab complete. This change is to
fix it.

Fixes: https://github.com/nodejs/node/issues/21201

PR-URL: https://github.com/nodejs/node/pull/21556
Fixes: https://github.com/nodejs/node/issues/21201
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
2018-07-02 23:04:04 +08:00
cjihrig
4dbfb096f0
Revert "repl: add friendly tips about how to exit repl"
This reverts commit 9aa4ec43fc.

This commit in question introduced a regression in repl.eval(),
as the context argument is no longer passed to runInContext().

PR-URL: https://github.com/nodejs/node/pull/20972
Fixes: https://github.com/nodejs/node/issues/20965
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
2018-05-28 13:53:26 -04:00
Ruben Bridgewater
f954aba39e
repl: make console, module and require non-enumerable
This aligns these globals with the regular context.

PR-URL: https://github.com/nodejs/node/pull/20717
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-05-19 17:55:55 +02:00
monkingxue
9aa4ec43fc
repl: add friendly tips about how to exit repl
Imitate python repl, when the user enters 'exit' or 'quit',
no longer prompt 'Reference Error', but
prompts 'To exit, press ^D or type .exit'.
If the user defines variables named 'exit' or 'quit' ,
only the value of the variables are output

PR-URL: https://github.com/nodejs/node/pull/20617
Fixes: https://github.com/nodejs/node/issues/19021
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-18 15:47:17 +02:00
Anna Henningsen
849aaaeeb0
Revert "util: change util.inspect depth default"
This reverts commit b994b8eff6.

This caused regressions in ecosystem code. While the change originally
was semver-major and could be postponed until after Node.js 10,
I think reverting it is a good choice at this point.

Also, I personally do not think defaulting to a shallow inspect
is a bad thing at all – quite the opposite: It makes `util.inspect()`
give an overview of an object, rather than providing a full
display of its contents. Changing the `depth` default to infinity
fundamentally changed the role that `util.inspect()` plays,
and makes output much more verbose and thus at times unusable
for `console.log()`-style debugging.

PR-URL: https://github.com/nodejs/node/pull/20017
Fixes: https://github.com/nodejs/node/issues/19405
Refs: https://github.com/nodejs/node/pull/17907
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-05-11 17:46:56 +02:00
cjihrig
17a4421b69
repl: add spaces to load/save messages
PR-URL: https://github.com/nodejs/node/pull/20536
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-05-05 13:39:11 +02:00
Timothy Gu
be92eab92a
repl: hide top-level await feature behind a flag
PR-URL: https://github.com/nodejs/node/pull/19604
Refs: https://github.com/nodejs/node/pull/17807
Refs: https://github.com/nodejs/node/pull/15566#issuecomment-353428430
Reviewed-By: Gus Caplan <me@gus.host>
2018-04-18 07:50:17 -07:00
Joyee Cheung
c2b01881dc
lib: restructure cjs and esm loaders
Create `lib/internal/modules` and restructure the module loaders
to make the purpose of those files clearer.

Also make it clear in the code that the object exported by
`lib/internal/modules/cjs/loader.js` is `CJSModule` instead of the
ambiguous `Module`.

Before:

```
lib
├── ...
├── internal
│       ├── loaders
│       │     ├── CreateDynamicModule.js
│       │     ├── DefaultResolve.js
│       │     ├── Loader.js
│       │     ├── ModuleJob.js
│       │     ├── ModuleMap.js
│       │     └── Translators.js
│       └── module.js
└── module.js
```

After:

```
lib
├── ...
├── internal
│       ├── ...
│       └── modules
│              ├── cjs
│              │     ├── helpers.js
│              │     └── loader.js
│              └── esm
│                    ├── CreateDynamicModule.js
│                    ├── DefaultResolve.js
│                    ├── Loader.js
│                    ├── ModuleJob.js
│                    ├── ModuleMap.js
│                    └── Translators.js
└── module.js # deleted in this commit to work with git file mode
```

PR-URL: https://github.com/nodejs/node/pull/19177
Refs: https://github.com/nodejs/node/pull/19112
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2018-03-15 20:50:35 +08:00
Prince J Wesley
ebfa8b1464
repl: better handling of recoverable errors
Below syntax errors are handled without force .break/clear
  - Unexpected Token (prefix errors)
  - missing ) after argument list

In the multiline expression, recoverable errors are truly
recoverable, otherwise syntax error will be thrown.

PR-URL: https://github.com/nodejs/node/pull/18915
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-03-11 03:28:18 +01:00
Ruben Bridgewater
4893f70d12
repl: remove magic mode
The magic mode is long deprecated and works the same as the sloppy
mode. Since the sloppy mode is the default, removing the magic mode
should be safe.

PR-URL: https://github.com/nodejs/node/pull/19187
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2018-03-11 02:43:27 +01:00
Michaël Zasso
1e8d110e64 lib: port errors to new system
This is a first batch of updates that touches non-underscored modules in
lib.

PR-URL: https://github.com/nodejs/node/pull/19034
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-03-05 19:51:30 +01:00
Anna Henningsen
a8b5192fef
repl: make last error available as _error
This is pretty useful when trying to inspect the last
error caught by a REPL, and is made to be analogous to `_`,
which contains the last successful completion value.

PR-URL: https://github.com/nodejs/node/pull/18919
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2018-03-04 22:01:57 +00:00
killagu
26231548ad
repl: fix tab-complete warning
When create a nest repl, will register `Runtime.executionContextCreated`
listener to the inspector session.This patch will fix listener
repeatedly register.

PR-URL: https://github.com/nodejs/node/pull/18881
Fixes: https://github.com/nodejs/node/issues/18284
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-22 15:07:05 +00:00
Ruben Bridgewater
96c57fbfaa
lib: switch to Number.isNaN
Number.isNaN is now as fast as `val !== val`. Switch to the more
readable version. Also switch all `isNaN` to `Number.isNaN`.

PR-URL: https://github.com/nodejs/node/pull/18744
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-02-16 18:09:56 +01:00
Ruben Bridgewater
1fc373bdf6
Revert "repl: refactor tests to not rely on timing"
This reverts commit de848ac1e0.

The commit broke multiline repl.

PR-URL: https://github.com/nodejs/node/pull/18715
Refs: https://github.com/nodejs/node/pull/17828
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-02-12 15:42:06 +01:00
Bradley Farias
de848ac1e0
repl: refactor tests to not rely on timing
Tests relying on synchronous timing have been migrated to use events.

PR-URL: https://github.com/nodejs/node/pull/17828
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-02-10 14:19:54 +01:00
Ruben Bridgewater
b994b8eff6
util: change util.inspect depth default
The current default is not ideal in most use cases. Therefore it is
changed to showing unlimited depth in case util.inspect is called
directly. The default is kept as before for console.log and similar.

Using console.dir will now show a depth of up to five and
console.assert / console.trace will show a unlimited depth.

PR-URL: https://github.com/nodejs/node/pull/17907
Refs: https://github.com/nodejs/node/issues/12693
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-01-16 15:34:03 +01:00
Ruben Bridgewater
11dda69a33
repl: refactor code for readability
PR-URL: https://github.com/nodejs/node/pull/17919
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Lance Ball <lball@redhat.com>
2018-01-04 21:21:22 +01:00
Ruben Bridgewater
80988f9322
repl: upper case comments first char
PR-URL: https://github.com/nodejs/node/pull/17919
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Lance Ball <lball@redhat.com>
2018-01-04 21:21:21 +01:00
kysnm
ab5a2aba38 repl: migrate errors to internal/errors
PR-URL: https://github.com/nodejs/node/pull/17716
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-22 13:27:25 -05:00
Michaël Zasso
416c0ec952 repl: show lexically scoped vars in tab completion
Use the V8 inspector protocol, if available, to query the list of
lexically scoped variables (defined with `let`, `const` or `class`).

PR-URL: https://github.com/nodejs/node/pull/16591
Fixes: https://github.com/nodejs/node/issues/983
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-21 14:47:29 +01:00
Ben Noordhuis
727339e9c2
repl: fix util.inspect() coloring regression
The `Object.assign()` calls introduced in commit 90a4390 ("repl: show
proxies as Proxy objects") mutated their first argument, causing the
`{ colors: true }` option from the REPL to leak over into the global
`util.inspect.defaultOptions` object.

Refs: https://github.com/nodejs/node/pull/16485#issuecomment-350428638

PR-URL: https://github.com/nodejs/node/pull/17565
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-12-12 12:49:32 -02:00
Timothy Gu
eeab7bc068
repl: support top-level await
Much of the AST visitor code was ported from Chrome DevTools code
written by Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>.

PR-URL: https://github.com/nodejs/node/pull/15566
Fixes: https://github.com/nodejs/node/issues/13209
Refs: e8111c396f
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-11-16 15:42:46 -08:00
Timothy Gu
ab64b6d799
repl: add async and await as keywords
PR-URL: https://github.com/nodejs/node/pull/15566
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-11-16 15:42:05 -08:00
Timothy Gu
cff6e69057
repl: add an internal "paused" mode
PR-URL: https://github.com/nodejs/node/pull/15566
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2017-11-16 15:42:03 -08:00
Weijia Wang
e22b8d0c46 lib: improve the usage of TypeError[INVALID_ARG_TYPE]
The initials of expected in TypeError[ERR_INVALID_ARG_TYPE]
are inconsistent. This change is to unify them.

PR-URL: https://github.com/nodejs/node/pull/16401
Fixes: https://github.com/nodejs/node/issues/16383
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-11-12 11:04:06 -08:00
Ben Noordhuis
90a43906ab repl: show proxies as Proxy objects
Before this commit they transparently invoked their magic methods but
that sometimes throws confusing exceptions with misbehaving proxies.

This change is not wholly uncontroversial but we can always change the
default if necessary.  Let's see how it goes.

Fixes: https://github.com/nodejs/node/issues/16483
PR-URL: https://github.com/nodejs/node/pull/16485
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-07 19:51:51 +01:00
James M Snell
3d20190a3a src: remove throws in set/getHiddenValue
These are internal only utility functions, CHECK instead of throw

PR-URL: https://github.com/nodejs/node/pull/16544
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-11-02 07:24:49 -07:00
James M Snell
67c8511ea1 src: use internal/errors for startSigintWatchdog
Move the throw out of c++ and into js using internal/errors

PR-URL: https://github.com/nodejs/node/pull/16546
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-11-01 21:42:15 -07:00
cPhost
bb59d2bd19
repl: avoid crashing from null and undefined errors
When `throw undefined` or `throw null` is executed, the REPL crashes.
This change does a check for `null|undefined` before accessing an
error's properties to prevent crashing.

Fixes: https://github.com/nodejs/node/issues/16545
Fixes: https://github.com/nodejs/node/issues/16607

PR-URL: https://github.com/nodejs/node/pull/16574
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2017-10-31 14:37:37 -04:00
Lance Ball
7a29f44071
repl: deprecate REPLServer.prototype.memory
This method is only useful for the internal mechanics of the REPLServer
and does not need to be exposed in user space. It was previously not
documented, so I believe a Runtime deprecation makes sense.

PR-URL: https://github.com/nodejs/node/pull/16242
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-10-19 14:58:26 -04:00
Weijia Wang
212de3c5ec
lib: use destructuring for some constants
This change is to unify the declaration for constants into using
destructuring on the top-level-module scope, reducing some redundant
code.

PR-URL: https://github.com/nodejs/node/pull/16063
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-10-16 23:34:32 +02:00
Jon Moss
0229e6746c repl: remove unused err argument
Not used by any callers in `lib/repl.js`, and is not public API.

PR-URL: https://github.com/nodejs/node/pull/16152
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-12 21:23:28 +08:00
Lance Ball
c5f54b1fad
repl: remove internal frames from runtime errors
When a user executes code in the REPLServer which generates an
exception, there is no need to display the REPLServer internal
stack frames.

PR-URL: https://github.com/nodejs/node/pull/15351
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

Refs: https://github.com/nodejs/node/pull/9601
2017-10-11 14:51:41 -04:00
Timothy Gu
7907534a8d
lib: faster type checks for some types
PR-URL: https://github.com/nodejs/node/pull/15663
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-01 23:58:59 -03:00
Ruben Bridgewater
da40050b59
repl: fix deprecation code
This slipped through while landing.

PR-URL: https://github.com/nodejs/node/pull/15668
Refs: https://github.com/nodejs/node/pull/15136
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-10-01 20:39:02 -03:00
Lance Ball
e416b3ee36
repl: deprecate turnOffEditorMode
This deprecates the current REPLServer.prototype.turnOffEditorMode
and adds a private function for turnOffEditorMode which handles the
necessary internal changes required instead of having them scattered
about.

PR-URL: https://github.com/nodejs/node/pull/15136
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-09-28 01:54:03 -03:00
Lance Ball
4bd44c11a5
repl: force editorMode in .load
The `.load` command would fail with any file that contains
multiline `.` operator expressions. This was particularly
noticeable when chaining promises or multi-line arrow
expressions.

This change Forces the REPL to be in `editorMode` while loading
a file from disk using the `.load` command.

Fixes: https://github.com/nodejs/node/issues/14022

PR-URL: https://github.com/nodejs/node/pull/14861
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-09-01 10:33:15 -04:00
Lance Ball
ed1ba4580b
repl: remove REPLServer.createContext side effects
The internal method `REPLServer.createContext()` had
unexpected side effects. When called, the value for the
`underscoreAssigned` and `lines` properties were reset.

This change ensures that those properties are not modified
when a context is created.

Fixes: https://github.com/nodejs/node/issues/14226
Refs: https://github.com/nodejs/node/issues/7619

PR-URL: https://github.com/nodejs/node/pull/14331
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-08-30 16:22:16 -04:00
Teddy Katz
b646a3df29
repl: include folder extensions in autocomplete
When autocompleting `require` calls, the repl strips .js file extensions
from results. However, stripping an extension from a directory results
in an error. Update the autocompletion logic to avoid stripping
extensions from directories.

PR-URL: https://github.com/nodejs/node/pull/14727
Fixes: https://github.com/nodejs/node/issues/14726
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
2017-08-13 01:03:30 -07:00
Lance Ball
766506a2e9
repl: deprecate REPLServer.parseREPLKeyword
This method does not need to be visible to user code. It has been
undocumented since it was introduced which was perhaps v0.8.9.

The motivation for this change is that the method is simply an
implementation detail of the REPLServer behavior, and does
not need to be exposed to user code.

This change adds documentation of the method with a deprecation
warning, and a test that the method is actually documented.

PR-RUL: https://github.com/nodejs/node/pull/14223
Refs: https://github.com/nodejs/node/issues/7619
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-02 14:39:06 -04:00
Lance Ball
2ca9f94e33
repl: make REPLServer.bufferedCommand private
The `REPLServer.bufferedCommand` property was undocumented, except
for its usage appearing, unexplained, in an example for
`REPLServer.defineCommand`. This commit deprecates that property,
privatizes it, and adds a `REPLServer.clearBufferedCommand()`
function that will clear the buffer.

PR-URL: https://github.com/nodejs/node/pull/13687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <mhdawson@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben.bridgewater@fintura.de>

Refs: https://github.com/nodejs/node/issues/12686
2017-08-01 22:45:28 +02:00
Shivanth MP
46d3ff2af9
repl: do not consider ... as a REPL command
This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: https://github.com/nodejs/node/issues/14426
PR-URL: https://github.com/nodejs/node/pull/14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-07-29 10:35:01 +02:00
Rich Trott
8cccdd96f5 lib: adjust indentation for impending lint change
ESLint 4.x provides stricter indentation linting than previous versions.
In preparation for enabling the stricter indentation linting, adjust the
indentation of four lines in lib/net.js and lib/repl.js.

PR-URL: https://github.com/nodejs/node/pull/14403
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
2017-07-24 13:55:44 -07:00
Alexey Orlenko
45b730ec42
repl: improve require() autocompletion
Currently REPL supports autocompletion for core modules and those found
in node_modules.  This commit adds tab completion for modules relative
to the current directory.

PR-URL: https://github.com/nodejs/node/pull/14409
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-24 17:10:43 +03:00
Sebastiaan Deckers
bb29405904
lib,src: fix consistent spacing inside braces
PR-URL: https://github.com/nodejs/node/pull/14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21 15:13:47 -04:00
Vse Mozhet Byt
4f87522244 doc, lib, test: do not re-require needlessly
PR-URL: https://github.com/nodejs/node/pull/14244
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
2017-07-21 20:40:52 +03:00
Benjamin Gruenbaum
030a0285d8 repl: don't terminate on null thrown
Previous behavior was to assume an error is a proper error in the
repl module. A check was added to not terminate the process on thrown
repl errors that are `null` or `undefined`.

PR-URL: https://github.com/nodejs/node/pull/14306
Fixes: https://github.com/nodejs/node/issues/12373
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
2017-07-19 12:20:09 +03:00