-
-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ts-node eval public for node REPL consumption #1121
Merged
Merged
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ffe2428
Add createReplEval function
MarcManiez 6c3ecbf
Add a test
MarcManiez c064d71
Fix a couple of typos
MarcManiez b6eca72
Actually test the evaluator
MarcManiez ada5afd
Try removing spec
MarcManiez 9ab7eca
Use service creation pattern
MarcManiez 58354c3
Move REPL code to its own file
MarcManiez 6d8a66f
Merge remote-tracking branch 'origin/master' into public-eval
cspotcode 02c174a
- Reorder repl.ts declarations to match the original order from bin.ts
cspotcode 95375d5
Expand ReplService API; use new API in bin.ts, which further decouple…
cspotcode 7acec12
Add brief, internal docs for REPL API
cspotcode b2f13e3
Add support for DI of alternative stdio streams into REPL
cspotcode d539f40
export REPL from index.ts
cspotcode 4164a37
remove unnecessary export
cspotcode 9b834b0
Add test for new REPL API
cspotcode 495475e
API surface, naming, docs tweaks
cspotcode 80f67ed
tweak identifiers
cspotcode d610300
Merge remote-tracking branch 'origin/master' into public-eval
cspotcode 354cb10
fix name
cspotcode 7f1a7a2
Tweak repl API test to match REPL CLI test, allowing it to pass on Wi…
cspotcode 5267c0b
Merge remote-tracking branch 'origin/master' into public-eval
cspotcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## How to create your own ts-node powered REPL | ||
|
||
- Create ts-node REPL service which includes EvalState | ||
- Create ts-node service using EvalState-aware `readFile` and `fileExists` implementations from REPL | ||
- Pass service to repl service | ||
- Either: | ||
- call REPL method start() to start a REPL | ||
- create your own node repl but pass it REPL service's eval() function | ||
|
||
|
||
``` | ||
const tsNodeReplService = tsNode.createReplService() | ||
const {readFile, fileExists} = repl.getStateAwareHostFunctions() | ||
const service = tsNode.register({ | ||
... options, | ||
readFile, | ||
fileExists | ||
}) | ||
tsNodeReplService.setService(service); | ||
tsNodeReplService.start(); | ||
|
||
// or | ||
const repl = require('repl').start({ | ||
... options, | ||
eval: tsNodeReplService.nodeReplEval | ||
}); | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks off - should it be
tsNodeReplService.getStateAwareHostFunctions()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
getStateAwareHostFunctions
was left over from the previous commit which renamedgetStateAwareHostFunctions
tocreateEvalAwarePartialHost
. So maybe this was the intent?