Skip to content

Commit

Permalink
support SIBILANT_REPL_HISTORY_FILE in env
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed May 18, 2016
1 parent 0730c3a commit e459f3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ var input = process.openStdin(),
readline = require("readline").createInterface(input, output),
context = undefined,
cmdBuffer = "",
HISTORY_FILE = (process.env.HOME + "/.sibilant.history"),
HISTORY_FILE = (process.env.SIBILANT_REPL_HISTORY_FILE || ("" + process.env.HOME + "/.sibilant.history")),
fd = undefined;
fs.access(HISTORY_FILE, fs.R_OK, (function() {
/* src/repl.sibilant:16:31 */
/* src/repl.sibilant:18:23 */

return (function() {
if (arguments[0]) {
return readline.history = fs.readFileSync(HISTORY_FILE, "utf-8").split("\n").reverse().filter((function() {
/* src/repl.sibilant:19:54 */
/* src/repl.sibilant:21:46 */

return (!!(arguments[0]));
}));
Expand All @@ -28,23 +28,23 @@ fs.access(HISTORY_FILE, fs.R_OK, (function() {
}));
fd = fs.openSync(HISTORY_FILE, "a");
var createContext = (function createContext$() {
/* create-context src/repl.sibilant:26:0 */
/* create-context src/repl.sibilant:28:0 */

var context = vm.createContext();
module.filename = (process.cwd() + "/exec");
context._sibilant = sibilant;
context.module = module;
context.require = require;
Object.keys(global).forEach((function(key) {
/* src/repl.sibilant:33:5 */
/* src/repl.sibilant:35:5 */

return context[key] = global[key];
}));
return context;
});
context = createContext();
var displayPrompt = (function displayPrompt$() {
/* display-prompt src/repl.sibilant:38:0 */
/* display-prompt src/repl.sibilant:40:0 */

var open = cmdBuffer.split((new RegExp("[\\{\\[\\(]", "g"))).length,
closed = cmdBuffer.split((new RegExp("[\\}\\]\\)]", "g"))).length,
Expand All @@ -69,7 +69,7 @@ var displayPrompt = (function displayPrompt$() {
return readline.prompt();
});
var handleLine = (function handleLine$(cmd) {
/* handle-line src/repl.sibilant:53:0 */
/* handle-line src/repl.sibilant:55:0 */

var jsLine = "";
(function() {
Expand Down Expand Up @@ -118,7 +118,7 @@ var handleLine = (function handleLine$(cmd) {
});
readline.on("line", handleLine);
readline.on("close", (function() {
/* src/repl.sibilant:98:20 */
/* src/repl.sibilant:96:20 */

fs.closeSync(fd);
output.write("\nexiting");
Expand Down
2 changes: 1 addition & 1 deletion maps/repl.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/repl.sibilant
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
readline (|> 'readline require (.create-interface input output))
context undefined
cmd-buffer ""
HISTORY-FILE (concat process.env.HOME "/.sibilant.history")
HISTORY-FILE (|> process.env.SIBILANT-REPL-HISTORY-FILE
(or (""process.env.HOME"/.sibilant.history")))
fd undefined)


Expand Down

0 comments on commit e459f3a

Please sign in to comment.