-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is done by adding a root level wrapper script for lib/coffee-script/repl, similar to how the register script is wrapped. This allows user programs to embed a CoffeeScript REPL without digging into CoffeeScript's internals.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
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,20 @@ | ||
### | ||
Example of embedding the CoffeeScript REPL, strikingly similar to the Node REPL. | ||
### | ||
|
||
# Require 'coffee-script/repl' to import the repl module | ||
repl = require '../repl' | ||
|
||
console.log 'Custom REPL! Type `sayHi()` to see what it does!' | ||
|
||
# Start the REPL with your configuration | ||
r = repl.start | ||
prompt: 'my-repl> ' | ||
|
||
# Fields added to the context object are exposed as variables in the REPL | ||
r.context.sayHi = -> console.log 'Hello' | ||
|
||
# An exit event is emitted when the user exits the REPL | ||
r.on 'exit', -> | ||
console.log 'Bye!' | ||
process.exit() |
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 @@ | ||
module.exports = require('./lib/coffee-script/repl'); |